tests: use TestMain() instead of Init() to compile mock-dnf-json
Lets us have teardown code so we can clean up the temporary directory where the binary was built.
This commit is contained in:
parent
86536f11e7
commit
b56ff56189
3 changed files with 20 additions and 3 deletions
|
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
var dnfjsonPath string
|
||||
|
||||
func init() {
|
||||
func setupDNFJSON() {
|
||||
// compile the mock-dnf-json binary to speed up tests
|
||||
tmpdir, err := os.MkdirTemp("", "")
|
||||
if err != nil {
|
||||
|
|
@ -573,3 +573,10 @@ func TestJobTypeValidation(t *testing.T) {
|
|||
test.TestRoute(t, handler, false, "GET", fmt.Sprintf("/api/composer-koji/v1/compose/%s%s", badID, path), ``, http.StatusNotFound, string(resp))
|
||||
}
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
setupDNFJSON()
|
||||
defer os.RemoveAll(dnfjsonPath)
|
||||
code := m.Run()
|
||||
os.Exit(code)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue