Skip to content

Commit

Permalink
add and modify test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
moricho committed Sep 3, 2020
1 parent 8f1cf78 commit 1f2e808
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 29 deletions.
34 changes: 34 additions & 0 deletions testdata/src/sample/cleanup_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package sample

import (
"testing"
)

func Test_Cleanup1(t *testing.T) { // want "Test_Cleanup1 should use t.Cleanup"
teardown := setup("Test_Cleanup1")
defer teardown()

t.Parallel()

t.Run("Cleanup1_Sub1", func(t *testing.T) {
call("Cleanup1_Sub1")
t.Parallel()
})

t.Run("Cleanup1_Sub2", func(t *testing.T) {
call("Cleanup1_Sub2")
})
}

func Test_Cleanup2(t *testing.T) { // OK
teardown := setup("Test_Cleanup2")
defer teardown()

t.Run("Cleanup2_Sub1", func(t *testing.T) {
call("Cleanup2_Sub1")
})

t.Run("Cleanup2_Sub2", func(t *testing.T) {
call("Cleanup2_Sub2")
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,3 @@ func Test_Func4(t *testing.T) { // OK
teardown := setup("Test_Func4")
defer teardown()
}

func Test_Func5(t *testing.T) { // want "Test_Func5 should use t.Cleanup"
teardown := setup("Test_Func5")
defer teardown()

t.Parallel()

t.Run("Func5_Sub1", func(t *testing.T) {
call("Func5_Sub1")
t.Parallel()
})

t.Run("Func5_Sub2", func(t *testing.T) {
call("Func1_Sub2")
})
}

func Test_Func6(t *testing.T) { // OK
teardown := setup("Test_Func6")
defer teardown()

t.Run("Func6_Sub1", func(t *testing.T) {
call("Func6_Sub1")
})

t.Run("Func6_Sub2", func(t *testing.T) {
call("Func6_Sub2")
})
}
28 changes: 28 additions & 0 deletions testdata/src/sample/table_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package sample

import (
"testing"
)

func Test_Table1(t *testing.T) { // want "Test_Table1 should call t.Parallel on the top level" "Test_Table1 should use t.Cleanup"
teardown := setup("Test_Func1")
defer teardown()

tests := []struct {
name string
}{
{
name: "Table1_Sub1",
},
{
name: "Table1_Sub2",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
call(tt.name)
})
}
}

0 comments on commit 1f2e808

Please sign in to comment.