tweak output formatting
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
2024-01-10 09:40:31 +11:00
parent a31b01af4d
commit 509f687d6b
6 changed files with 126 additions and 11 deletions

View File

@@ -102,7 +102,7 @@ func BodyContains(testCase *TestCase) (bool, error) {
// search through all the results to see if the expected value is there
for i := range results {
if strings.Contains(results[i].(string), v) {
fmt.Printf("Expected value of '%s' matches, success\n", v)
fmt.Printf("Expected value of '%s' matches\n", v)
checkFound = true
break
}
@@ -123,13 +123,25 @@ func BodyContains(testCase *TestCase) (bool, error) {
func BodyHasKeys(testCase *TestCase) (bool, error) {
for _, key := range testCase.Expect.Body.HasKeys {
// If the body response was json then we stored it already when running the test
if _, ok := testCase.ResultBodyMap[key]; ok {
//fmt.Printf("Confirmed body has key '%s'\n", key)
results := findKey(key, testCase.ResultBodyMap)
if len(results) > 0 {
fmt.Printf("Found key '%s' with values %v\n", key, results)
} else {
fmt.Printf("Body HasKeys test failed, expected key '%s' not found\n", key)
return false, nil
}
/*
// If the body response was json then we stored it already when running the test
if _, ok := testCase.ResultBodyMap[key]; ok {
//fmt.Printf("Confirmed body has key '%s'\n", key)
} else {
fmt.Printf("Body HasKeys test failed, expected key '%s' not found\n", key)
return false, nil
}
*/
}
return true, nil