Skip to content

Commit

Permalink
fix some typos in tests
Browse files Browse the repository at this point in the history
Signed-off-by: hishope <[email protected]>
  • Loading branch information
hishope committed Mar 7, 2024
1 parent 3e2c4fc commit 5557d0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions tests/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func TestCreateWithAutoIncrementCompositeKey(t *testing.T) {
}

func TestCreateOnConflictWithDefaultNull(t *testing.T) {
type OnConfilctUser struct {
type OnConflictUser struct {
ID string
Name string `gorm:"default:null"`
Email string
Expand All @@ -594,32 +594,32 @@ func TestCreateOnConflictWithDefaultNull(t *testing.T) {
err = DB.AutoMigrate(&OnConfilctUser{})
AssertEqual(t, err, nil)

u := OnConfilctUser{
ID: "on-confilct-user-id",
Name: "on-confilct-user-name",
Email: "on-confilct-user-email",
Mobile: "on-confilct-user-mobile",
u := OnConflictUser{
ID: "on-conflict-user-id",
Name: "on-conflict-user-name",
Email: "on-conflict-user-email",
Mobile: "on-conflict-user-mobile",
}
err = DB.Create(&u).Error
AssertEqual(t, err, nil)

u.Name = "on-confilct-user-name-2"
u.Email = "on-confilct-user-email-2"
u.Name = "on-conflict-user-name-2"
u.Email = "on-conflict-user-email-2"
u.Mobile = ""
err = DB.Clauses(clause.OnConflict{UpdateAll: true}).Create(&u).Error
AssertEqual(t, err, nil)

var u2 OnConfilctUser
err = DB.Where("id = ?", u.ID).First(&u2).Error
AssertEqual(t, err, nil)
AssertEqual(t, u2.Name, "on-confilct-user-name-2")
AssertEqual(t, u2.Email, "on-confilct-user-email-2")
AssertEqual(t, u2.Name, "on-conflict-user-name-2")
AssertEqual(t, u2.Email, "on-conflict-user-email-2")
AssertEqual(t, u2.Mobile, "133xxxx")
}

func TestCreateFromMapWithoutPK(t *testing.T) {
if !isMysql() {
t.Skipf("This test case skipped, because of only supportting for mysql")
t.Skipf("This test case skipped, because of only supporting for mysql")
}

// case 1: one record, create from map[string]interface{}
Expand Down
4 changes: 2 additions & 2 deletions tests/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1413,10 +1413,10 @@ func TestMigrateSameEmbeddedFieldName(t *testing.T) {
err = DB.Table("game_users").AutoMigrate(&GameUser1{})
AssertEqual(t, nil, err)

_, err = findColumnType(&GameUser{}, "stat_ab_ground_destory_count")
_, err = findColumnType(&GameUser{}, "stat_ab_ground_destroy_count")
AssertEqual(t, nil, err)

_, err = findColumnType(&GameUser{}, "rate_ground_rb_ground_destory_count")
_, err = findColumnType(&GameUser{}, "rate_ground_rb_ground_destroy_count")
AssertEqual(t, nil, err)
}

Expand Down

0 comments on commit 5557d0b

Please sign in to comment.