From 6a6b8b785adb11fb4268ad67f9ffbe9574b8b20e Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Thu, 8 Nov 2018 20:49:04 +0100 Subject: [PATCH] Null tests --- tests/null_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/null_test.go diff --git a/tests/null_test.go b/tests/null_test.go new file mode 100644 index 0000000..e33f922 --- /dev/null +++ b/tests/null_test.go @@ -0,0 +1,24 @@ +package tests + +import ( + "fmt" + "testing" + + "github.com/localhots/bocadillo/mysql" +) + +func TestNull(t *testing.T) { + tbl := suite.createTable(mysql.ColumnTypeTiny, "", attrUnsigned|attrAllowNull) + defer tbl.drop(t) + + uint8p := func(v uint8) *uint8 { return &v } + for _, v := range []*uint8{uint8p(0), uint8p(1), nil} { + strv := "NULL" + if v != nil { + strv = fmt.Sprint(*v) + } + t.Run(strv, func(t *testing.T) { + suite.insertAndCompare(t, tbl, v) + }) + } +}