From d178c41a4c2cfa95be61235f047d2d8957215613 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Tue, 22 Oct 2024 11:55:56 -0700 Subject: [PATCH] Update tests. --- lib/typing/parse_test.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/typing/parse_test.go b/lib/typing/parse_test.go index a5bb1df7b..39674d924 100644 --- a/lib/typing/parse_test.go +++ b/lib/typing/parse_test.go @@ -1,7 +1,6 @@ package typing import ( - "errors" "fmt" "math" "testing" @@ -10,6 +9,21 @@ import ( ) func Test_ParseValue(t *testing.T) { + { + // Invalid + { + // Unknown data type + type Dusty struct{} + var dusty Dusty + _, err := ParseValue("dusty", nil, dusty) + assert.ErrorContains(t, err, "unknown type: typing.Dusty, value: {}") + } + { + // Another unknown data type + _, err := ParseValue("", nil, fmt.Errorf("hello there")) + assert.ErrorContains(t, err, "unknown type: *errors.errorString, value: hello there") + } + } { // Optional schema exists, so we are using it optionalSchema := map[string]KindDetails{"created_at": String} @@ -17,11 +31,6 @@ func Test_ParseValue(t *testing.T) { assert.Equal(t, String, MustParseValue("created_at", optionalSchema, val)) } } - { - // Invalid - assert.Equal(t, MustParseValue("", nil, nil), Invalid) - assert.Equal(t, MustParseValue("", nil, errors.New("hello")), Invalid) - } { // Nil assert.Equal(t, MustParseValue("", nil, ""), String)