Skip to content

Commit

Permalink
clean testdata after running unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AbelHu committed Oct 22, 2024
1 parent 7d0e774 commit 99c47ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions admission-webhook/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,6 @@ func Test_env_bool(t *testing.T) {
func TestMain(m *testing.M) {
GenerateTestCertAndKey()
code := m.Run() // run tests
ClearTestdata()
os.Exit(code)
}
4 changes: 4 additions & 0 deletions admission-webhook/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,7 @@ func GenerateTestCertAndKey() {
pem.Encode(keyFile, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: keyBytes})
keyFile.Close()
}

func ClearTestdata() {
os.RemoveAll("testdata")
}

0 comments on commit 99c47ca

Please sign in to comment.