Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle https://xorm.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
787B

  1. // Copyright 2019 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestSplitColStr(t *testing.T) {
  10. var kases = []struct {
  11. colStr string
  12. fields []string
  13. }{
  14. {
  15. colStr: "`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL",
  16. fields: []string{
  17. "`id`", "INTEGER", "PRIMARY", "KEY", "AUTOINCREMENT", "NOT", "NULL",
  18. },
  19. },
  20. {
  21. colStr: "`created` DATETIME DEFAULT '2006-01-02 15:04:05' NULL",
  22. fields: []string{
  23. "`created`", "DATETIME", "DEFAULT", "'2006-01-02 15:04:05'", "NULL",
  24. },
  25. },
  26. }
  27. for _, kase := range kases {
  28. assert.EqualValues(t, kase.fields, splitColStr(kase.colStr))
  29. }
  30. }