diff --git a/main_test.go b/main_test.go index 60a388f7..d6975d26 100644 --- a/main_test.go +++ b/main_test.go @@ -8,13 +8,25 @@ import ( // GORM_BRANCH: master // TEST_DRIVERS: sqlite, mysql, postgres, sqlserver -func TestGORM(t *testing.T) { - user := User{Name: "jinzhu"} +type Book struct { + BookID int `gorm:"column:book_id;autoIncrement:true;autoIncrementIncrement:10"` + Name string `gorm:"column:name;type:varchar(255)"` +} - DB.Create(&user) +func TestGORM(t *testing.T) { + err := DB.AutoMigrate(&Book{}) + if err != nil { + t.Error(err.Error()) + } + var increment int + err = DB.Raw(`select increment from information_schema.sequences where sequence_name = 'books_book_id_seq'`). + Scan(&increment).Error + if err != nil { + t.Error(err.Error()) + } - var result User - if err := DB.First(&result, user.ID).Error; err != nil { - t.Errorf("Failed, got error: %v", err) + // should be 10, but actually get 1 + if increment != 10 { + t.Error("auto increment should be 10, but get", increment) } }