(t *testing.T)
| 502 | } |
| 503 | |
| 504 | func TestFirstOrCreateWithPrimaryKey(t *testing.T) { |
| 505 | company := Company{ID: 100, Name: "company100_with_primarykey"} |
| 506 | DB.FirstOrCreate(&company) |
| 507 | |
| 508 | if company.ID != 100 { |
| 509 | t.Errorf("invalid primary key after creating, got %v", company.ID) |
| 510 | } |
| 511 | |
| 512 | companies := []Company{ |
| 513 | {ID: 101, Name: "company101_with_primarykey"}, |
| 514 | {ID: 102, Name: "company102_with_primarykey"}, |
| 515 | } |
| 516 | DB.Create(&companies) |
| 517 | |
| 518 | if companies[0].ID != 101 || companies[1].ID != 102 { |
| 519 | t.Errorf("invalid primary key after creating, got %v, %v", companies[0].ID, companies[1].ID) |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | func TestCreateFromSubQuery(t *testing.T) { |
| 524 | user := User{Name: "jinzhu"} |
nothing calls this directly
no test coverage detected