Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 22, 2024
1 parent e1a499c commit d178c41
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/typing/parse_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package typing

import (
"errors"
"fmt"
"math"
"testing"
Expand All @@ -10,18 +9,28 @@ 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}
for _, val := range []any{"2023-01-01", nil} {
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)
Expand Down

0 comments on commit d178c41

Please sign in to comment.