From bd512f805829f6af6419384c5c0cc6d5ae366486 Mon Sep 17 00:00:00 2001 From: Ian Howell Date: Fri, 22 Mar 2019 15:15:45 -0500 Subject: [PATCH] Updates to unit tests Signed-off-by: Ian Howell --- pkg/chartutil/values_test.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/chartutil/values_test.go b/pkg/chartutil/values_test.go index 7b4affef3..5dd5693b3 100644 --- a/pkg/chartutil/values_test.go +++ b/pkg/chartutil/values_test.go @@ -20,7 +20,6 @@ import ( "bytes" "encoding/json" "fmt" - "strings" "testing" "text/template" @@ -196,20 +195,17 @@ func TestValidateAgainstSchemaNegative(t *testing.T) { var errString string if err := ValidateAgainstSchema(values, schema); err == nil { - t.Errorf("Expected an error, but got nil") + t.Fatalf("Expected an error, but got nil") } else { errString = err.Error() } - if !strings.Contains(errString, "values don't meet the specification of the schema:") { - t.Errorf("Error string does not contain expected string: \"values don't meet the specification of the schema:\"") - } - if !strings.Contains(errString, "- (root): employmentInfo is required") { - t.Errorf("Error string does not contain expected string: \"- (root): employmentInfo is required\"") - } - - if !strings.Contains(errString, "- age: Must be greater than or equal to 0/1") { - t.Errorf("Error string does not contain expected string: \"- age: Must be greater than or equal to 0/1\"") + expectedErrString := `values don't meet the specification of the schema: +- (root): employmentInfo is required +- age: Must be greater than or equal to 0/1 +` + if errString != expectedErrString { + t.Errorf("Error string :\n`%s`\ndoes not match expected\n`%s`", errString, expectedErrString) } } @@ -600,14 +596,17 @@ phoneNumbers: - "(555) 555-5555" ` - values, _ := ReadValues([]byte(doc)) + values, err := ReadValues([]byte(doc)) + if err != nil { + t.Fatalf("Error reading values: %s", err) + } schema := GenerateSchema(values) assertEqualProperty(t, ".title", "Values", schema) assertEqualProperty(t, ".type", "object", schema) assertEqualProperty(t, ".properties.firstname.type", "string", schema) assertEqualProperty(t, ".properties.lastname.type", "string", schema) assertEqualProperty(t, ".properties.age.type", "number", schema) - assertEqualProperty(t, ".properties.likesCoffee.type", "bool", schema) + assertEqualProperty(t, ".properties.likesCoffee.type", "boolean", schema) assertEqualProperty(t, ".properties.employmentInfo.type", "object", schema) assertEqualProperty(t, ".properties.employmentInfo.object.title.type", "string", schema) assertEqualProperty(t, ".properties.employmentInfo.object.salary.type", "number", schema)