From 80aaa6b6e8d413a3382b409a07df1c8a8010a441 Mon Sep 17 00:00:00 2001 From: Liz Rice Date: Mon, 21 Dec 2020 15:19:40 +0000 Subject: [PATCH] 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 --- app_test.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/app_test.go b/app_test.go index d68bdce..70a67f6 100644 --- a/app_test.go +++ b/app_test.go @@ -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)