@@ -25,7 +25,7 @@ import (
2525)
2626
2727func TestClean_Success (t * testing.T ) {
28- root := t . TempDir ()
28+ t . Parallel ()
2929 libraryName := "testlib"
3030 for _ , test := range []struct {
3131 name string
@@ -37,30 +37,53 @@ func TestClean_Success(t *testing.T) {
3737 wantSnippets []string
3838 }{
3939 {
40- name : "removes all except keep list" ,
41- outputFiles : []string {"file1.go" , "file2.go" , "go.mod" },
40+ name : "removes all generated files" ,
41+ outputFiles : []string {
42+ "apiv1/.repo-metadata.json" ,
43+ "apiv1/auxiliary.go" ,
44+ "apiv1/auxiliary_go123.go" ,
45+ "apiv1/doc.go" ,
46+ "apiv1/library_client.go" ,
47+ "apiv1/library_client_example_go123_test.go" ,
48+ "apiv1/library_client_example_test.go" ,
49+ "apiv1/gapic_metadata.json" ,
50+ "apiv1/helpers.go" ,
51+ "apiv1/librarypb/content.pb.go" ,
52+ "apiv1/non-generated.go" ,
53+ "doc.go" ,
54+ },
4255 snippetFiles : []string {"snippet1.go" , "snippet2.go" , "README.md" },
43- keep : []string {"file1.go" },
44- wantOutput : []string {"file1.go" },
56+ keep : []string {},
57+ wantOutput : []string {
58+ "apiv1/non-generated.go" ,
59+ // skipped because the file doesn't live in a versioned directory.
60+ "doc.go" ,
61+ },
4562 },
4663 {
47- name : "remove all files" ,
48- outputFiles : []string {"file1.go" , "file2.go" },
64+ name : "remove all generated files except keep list" ,
65+ outputFiles : []string {
66+ "apiv1/auxiliary.go" ,
67+ "apiv1/auxiliary_go123.go" ,
68+ "nested/apiv1/doc.go" ,
69+ },
4970 snippetFiles : []string {"snippet1.go" },
50- keep : []string {},
51- wantOutput : []string {},
71+ keep : []string {"apiv1/auxiliary_go123.go" },
72+ wantOutput : []string {"apiv1/auxiliary_go123.go" },
5273 },
5374 {
5475 name : "nested module" ,
55- outputFiles : []string {"file1.go" , "file2.go" , " nested/nested_file .go" },
76+ outputFiles : []string {"nested/apiv1beta1/doc .go" },
5677 snippetFiles : []string {"nested/snippet.go" },
5778 keep : []string {},
5879 nestedModule : "nested" ,
59- wantOutput : []string {"nested/nested_file .go" },
80+ wantOutput : []string {"nested/apiv1beta1/doc .go" },
6081 wantSnippets : []string {"internal/generated/snippets/testlib/nested/snippet.go" },
6182 },
6283 } {
6384 t .Run (test .name , func (t * testing.T ) {
85+ t .Parallel ()
86+ root := t .TempDir ()
6487 outputPath := filepath .Join (root , libraryName )
6588 snippetPath := filepath .Join (root , "internal" , "generated" , "snippets" , libraryName )
6689 lib := & config.Library {
@@ -98,8 +121,7 @@ func TestClean_Success(t *testing.T) {
98121 }
99122}
100123
101- func TestCleanGo_Error (t * testing.T ) {
102- root := t .TempDir ()
124+ func TestClean_Error (t * testing.T ) {
103125 libraryName := "testlib"
104126 for _ , test := range []struct {
105127 name string
@@ -117,6 +139,7 @@ func TestCleanGo_Error(t *testing.T) {
117139 },
118140 } {
119141 t .Run (test .name , func (t * testing.T ) {
142+ root := t .TempDir ()
120143 outputPath := filepath .Join (root , libraryName )
121144 snippetPath := filepath .Join (root , "internal" , "generated" , "snippets" , libraryName )
122145 lib := & config.Library {
0 commit comments