github.com/octohelm/storage@v0.0.0-20240516030302-1ac2cc1ea347/internal/sql/adapter/sqlite/catalog_test.go (about) 1 package sqlite 2 3 import ( 4 "bytes" 5 "testing" 6 7 "github.com/octohelm/storage/internal/testutil" 8 ) 9 10 func Test_parseSQL(t *testing.T) { 11 cols := extractCols(bytes.NewBuffer([]byte(` 12 CREATE TABLE t_user ( 13 f_id UNSIGNED BIG INT NOT NULL, 14 f_name TEXT NOT NULL DEFAULT '', 15 f_nickname TEXT NOT NULL DEFAULT '', 16 f_username TEXT NOT NULL DEFAULT '', 17 f_gender INTEGER NOT NULL DEFAULT '0', 18 f_created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 19 f_updated_at BIGINT NOT NULL DEFAULT '0', 20 PRIMARY KEY (f_id) 21 ) 22 `))) 23 testutil.Expect(t, cols, testutil.Equal(map[string]string{ 24 "f_gender": "INTEGER NOT NULL DEFAULT '0'", 25 "f_created_at": "timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP", 26 "f_updated_at": "BIGINT NOT NULL DEFAULT '0'", 27 "PRIMARY": "KEY ( f_id )", 28 "f_id": "UNSIGNED BIG INT NOT NULL", 29 "f_name": "TEXT NOT NULL DEFAULT ''", 30 "f_nickname": "TEXT NOT NULL DEFAULT ''", 31 "f_username": "TEXT NOT NULL DEFAULT ''", 32 })) 33 }