(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func TestProcessDir(t *testing.T) { |
| 146 | t.Parallel() |
| 147 | |
| 148 | dir := t.TempDir() |
| 149 | |
| 150 | testFile := `package foo_test |
| 151 | |
| 152 | import "testing" |
| 153 | |
| 154 | func TestFoo(t *testing.T) { |
| 155 | t.Log("hello") |
| 156 | } |
| 157 | ` |
| 158 | nonTestFile := `package foo |
| 159 | |
| 160 | func Foo() {} |
| 161 | ` |
| 162 | |
| 163 | require.NoError(t, os.WriteFile(filepath.Join(dir, "foo_test.go"), []byte(testFile), 0644)) |
| 164 | require.NoError(t, os.WriteFile(filepath.Join(dir, "foo.go"), []byte(nonTestFile), 0644)) |
| 165 | |
| 166 | require.NoError(t, processDir(dir)) |
| 167 | |
| 168 | got, err := os.ReadFile(filepath.Join(dir, "foo_test.go")) |
| 169 | require.NoError(t, err) |
| 170 | require.Contains(t, string(got), "t.Parallel()") |
| 171 | |
| 172 | got, err = os.ReadFile(filepath.Join(dir, "foo.go")) |
| 173 | require.NoError(t, err) |
| 174 | require.Equal(t, nonTestFile, string(got)) |
| 175 | } |
nothing calls this directly
no test coverage detected