Skip to content

Commit

Permalink
add enum tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaGiorgadze committed Dec 27, 2023
1 parent 1a0d5a0 commit 6fe8b97
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions gonull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,28 @@ func TestConvertToTypeFromInt64(t *testing.T) {
}
}

func TestNullableScanWithCustomEnum(t *testing.T) {
type TestEnum int

const (
TestEnumA TestEnum = iota
TestEnumB
)

type TestModel struct {
ID int
Field gonull.Nullable[TestEnum]
}

testValue := TestEnumA
model := TestModel{ID: 1, Field: gonull.NewNullable(testValue)}

err := model.Field.Scan(testValue)
if err != nil {
assert.Error(t, err, "Scan failed with unsupported type conversion")
}
}

type testStruct struct {
Foo gonull.Nullable[*string] `json:"foo"`
}
Expand Down

0 comments on commit 6fe8b97

Please sign in to comment.