Skip to content

Commit

Permalink
test: Add NULL values to test data types
Browse files Browse the repository at this point in the history
  • Loading branch information
cjfinnell committed Dec 18, 2023
1 parent 0e38936 commit 403f70c
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,27 @@ func TestVerifyData(t *testing.T) {
}

columnTypes := map[string][]string{
"boolean": {"true", "false"},
"bytea": {fmt.Sprintf("'%s'", hex.EncodeToString([]byte("convert this content to bytes")))},
"bit(1)": {"'1'", "'0'"},
"varbit(3)": {"'0'", "'1'", "'101'", "'010'"},

"bigint[]": {"'{602213950000000000, -1}'"},
"integer": {"0", "123979", "-23974"},
"double precision": {"69.123987", "-69.123987"},

"text": {`'foo'`, `'bar'`, `''`, `'something that is much longer but without much other complication'`},
"uuid": {fmt.Sprintf("'%s'", uuid.New().String())},
`character varying(64)`: {`'more string stuff'`},

"jsonb": {`'{}'`, `'{"foo": ["bar", "baz"]}'`, `'{"foo": "bar"}'`, `'{"foo": "bar", "baz": "qux"}'`, `'{"for sure?": true, "has numbers": 123.456, "this is": ["some", "json", "blob"]}'`},
"json": {`'{}'`, `'{"foo": ["bar", "baz"]}'`, `'{"foo": "bar"}'`, `'{"foo": "bar", "baz": "qux"}'`, `'{"for sure?": true, "has numbers": 123.456, "this is": ["some", "json", "blob"]}'`},

"date": {`'2020-12-31'`},
"timestamp with time zone": {`'2020-12-31 23:59:59 -8:00'`, `'2022-06-08 20:03:06.957223+00'`}, // hashes differently for psql/crdb, convert to epoch when hashing
"timestamp without time zone": {`'2020-12-31 23:59:59'`},
"boolean": {"true", "false", "NULL"},
"bytea": {fmt.Sprintf("'%s'", hex.EncodeToString([]byte("convert this content to bytes"))), "NULL"},
"bit(1)": {"'1'", "'0'", "NULL"},
"varbit(3)": {"'0'", "'1'", "'101'", "'010'", "NULL"},

"bigint[]": {"'{602213950000000000, -1}'", "NULL"},
"integer": {"0", "123979", "-23974", "NULL"},
"double precision": {"69.123987", "-69.123987", "NULL"},

"text": {`'foo'`, `'bar'`, `''`, `'something that is much longer but without much other complication'`, `NULL`},
"text not null": {`'foo'`, `'bar'`, `''`, `'something that is much longer but without much other complication'`},
"uuid": {fmt.Sprintf("'%s'", uuid.New().String()), fmt.Sprintf("'%s'", uuid.New().String()), "NULL"},
`character varying(64)`: {`'more string stuff'`, "NULL"},

"jsonb": {`'{}'`, `'{"foo": ["bar", "baz"]}'`, `'{"foo": "bar"}'`, `'{"foo": "bar", "baz": "qux"}'`, `'{"for sure?": true, "has numbers": 123.456, "this is": ["some", "json", "blob"]}'`, "NULL"},
"json": {`'{}'`, `'{"foo": ["bar", "baz"]}'`, `'{"foo": "bar"}'`, `'{"foo": "bar", "baz": "qux"}'`, `'{"for sure?": true, "has numbers": 123.456, "this is": ["some", "json", "blob"]}'`, "NULL"},

"date": {`'2020-12-31'`, "NULL"},
"date not null": {`'2020-12-31'`},
"timestamp with time zone": {`'2020-12-31 23:59:59 -8:00'`, `'2022-06-08 20:03:06.957223+00'`, "NULL"}, // hashes differently for psql/crdb, convert to epoch when hashing
"timestamp without time zone": {`'2020-12-31 23:59:59'`, "NULL"},
}
keys := make([]string, len(columnTypes))
keysWithTypes := make([]string, len(columnTypes))
Expand Down

0 comments on commit 403f70c

Please sign in to comment.