Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
gkampitakis committed Jun 24, 2023
1 parent 7d3c797 commit 9c82ed3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
13 changes: 6 additions & 7 deletions snaps/skip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ func TestSkip(t *testing.T) {
// This is for populating skippedTests.values and following the normal flow
SkipNow(mockT)

test.True(t, testSkipped("TestMock/Skip", runOnly))
test.Equal(
test.True(t, testSkipped("TestMock/Skip - 1000", runOnly))
test.True(
t,
true,
testSkipped("TestMock/Skip/child_should_also_be_skipped", runOnly),
)
test.False(t, testSkipped("TestAnotherTest", runOnly))
Expand All @@ -174,10 +173,10 @@ func TestSkip(t *testing.T) {
// This is for populating skippedTests.values and following the normal flow
SkipNow(mockT)

test.True(t, testSkipped("Test", runOnly))
test.True(t, testSkipped("Test/chid", runOnly))
test.False(t, testSkipped("TestMock", runOnly))
test.False(t, testSkipped("TestMock/child", runOnly))
test.True(t, testSkipped("Test - 1", runOnly))
test.True(t, testSkipped("Test/child - 1", runOnly))
test.False(t, testSkipped("TestMock - 1", runOnly))
test.False(t, testSkipped("TestMock/child - 1", runOnly))
})

t.Run("should use regex match for runOnly", func(t *testing.T) {
Expand Down
10 changes: 3 additions & 7 deletions snaps/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,17 @@ type syncRegistry struct {
// Returns the id of the test in the snapshot
// Form [<test-name> - <occurrence>]
func (s *syncRegistry) getTestID(tName, snapPath string) string {
occurrence := 1
s.Lock()

if _, exists := s.values[snapPath]; !exists {
s.values[snapPath] = make(map[string]int)
}

if c, exists := s.values[snapPath][tName]; exists {
occurrence = c + 1
}

s.values[snapPath][tName] = occurrence
s.values[snapPath][tName]++
c := s.values[snapPath][tName]
s.Unlock()

return fmt.Sprintf("[%s - %d]", tName, occurrence)
return fmt.Sprintf("[%s - %d]", tName, c)
}

func newRegistry() *syncRegistry {
Expand Down

0 comments on commit 9c82ed3

Please sign in to comment.