From dc14cb14b03e1f50e3a3ca1edd83b2e09261dbd4 Mon Sep 17 00:00:00 2001 From: Liz Rice Date: Fri, 3 Jan 2020 14:02:49 +0000 Subject: [PATCH] Update tests for check states (#550) - Tests that did not increase coverage and were redundant are removed. - New tests reflecting the meaning of the state as explained in the README are added. Co-authored-by: s-nirali <25746945+s-nirali@users.noreply.github.com> --- check/check_test.go | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/check/check_test.go b/check/check_test.go index e946428..4d4e695 100644 --- a/check/check_test.go +++ b/check/check_test.go @@ -15,6 +15,7 @@ package check import ( + "os/exec" "testing" ) @@ -27,10 +28,27 @@ func TestCheck_Run(t *testing.T) { testCases := []TestCase{ {check: Check{Type: MANUAL}, Expected: WARN}, {check: Check{Type: "skip"}, Expected: INFO}, - {check: Check{Type: "", Scored: false}, Expected: WARN}, // Not scored checks with no type should be marked warn - {check: Check{Type: "", Scored: true}, Expected: WARN}, // If there are no tests in the check, warn - {check: Check{Type: MANUAL, Scored: false}, Expected: WARN}, - {check: Check{Type: "skip", Scored: false}, Expected: INFO}, + + {check: Check{Scored: false}, Expected: WARN}, // Not scored checks with no type, or not scored failing tests are marked warn + { + check: Check{ // Not scored checks with passing tests are marked pass + Scored: false, + Audit: ":", Commands: []*exec.Cmd{exec.Command("")}, + Tests: &tests{TestItems: []*testItem{&testItem{}}}, + }, + Expected: PASS, + }, + + {check: Check{Scored: true}, Expected: WARN}, // If there are no tests in the check, warn + {check: Check{Scored: true, Tests: &tests{}}, Expected: FAIL}, // If there are tests that are not passing, fail + { + check: Check{ // Scored checks with passing tests are marked pass + Scored: true, + Audit: ":", Commands: []*exec.Cmd{exec.Command("")}, + Tests: &tests{TestItems: []*testItem{&testItem{}}}, + }, + Expected: PASS, + }, } for _, testCase := range testCases {