generate: Fix testGenerateRun so that it actually works

This commit is contained in:
Sasha Koshka 2025-07-08 11:38:00 -04:00
parent a9d5bb83a2
commit c70c23d137
2 changed files with 33 additions and 6 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/generate/test

View File

@ -7,10 +7,14 @@ import "testing"
import "path/filepath" import "path/filepath"
func testGenerateRun(test *testing.T, protocol *Protocol, imports string, testCase string) { func testGenerateRun(test *testing.T, protocol *Protocol, imports string, testCase string) {
// open files // reset data directory
dir, err := os.MkdirTemp(os.TempDir(), "hopp-generate-test-*") dir := "test/generate-run"
err := os.RemoveAll(dir)
if err != nil { test.Fatal(err) } if err != nil { test.Fatal(err) }
defer os.RemoveAll(dir) err = os.MkdirAll(dir, 0750)
if err != nil { test.Fatal(err) }
// open files
sourceFile, err := os.Create(filepath.Join(dir, "protocol.go")) sourceFile, err := os.Create(filepath.Join(dir, "protocol.go"))
if err != nil { test.Fatal(err) } if err != nil { test.Fatal(err) }
defer sourceFile.Close() defer sourceFile.Close()