Don't rely on test ordering

Tests can be run in parallel so we can't rely on the state of a global
variable that is modified in one test being ready when we run another
This commit is contained in:
Liz Rice 2020-12-21 15:19:40 +00:00
parent 59d2148c4c
commit 80aaa6b6e8

View file

@ -8,7 +8,6 @@ import (
var (
cfgdir = "./cfg"
ver = "1.1.0"
path string
)
// Tests all standard linux-bench defintion files
@ -31,20 +30,12 @@ func TestGetDefinitionFilePath(t *testing.T) {
}
}
func TestGetControls(t *testing.T) {
var err error
path, err = getDefinitionFilePath(ver)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
_, err = getControls(path, nil)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
}
func TestRunControls(t *testing.T) {
path, err := getDefinitionFilePath(ver)
if err != nil {
t.Errorf("unexpected error: %s\n", err)
}
control, err := getControls(path, nil)
if err != nil {
t.Errorf("unexpected error: %s\n", err)