Skip to content

Commit

Permalink
feat: update TestDeleteTag
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Jan 5, 2024
1 parent 8dc57bc commit eb979fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func initTestHoles() {
}
tag := Tag{Name: "114", Temperature: 15}
holes[1].Tags = Tags{&tag}
holes[2].Tags = Tags{&tag}
holes[2].Tags = Tags{&tag} // here it will insert twice in latest version gorm
holes[3].Tags = Tags{{Name: "111", Temperature: 23}, {Name: "222", Temperature: 45}}
err := DB.Create(&holes).Error
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion tests/tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ func TestModifyTag(t *testing.T) {
func TestDeleteTag(t *testing.T) {

// Move holes to existed tag
id := 5
fromName := "1"
toName := "6"
var id int
DB.Model(Tag{}).Where("name = ?", fromName).Pluck("id", &id)
data := Map{"to": toName}
testAPI(t, "delete", "/api/tags/"+strconv.Itoa(id), 200, data)
var tag Tag
Expand Down

0 comments on commit eb979fa

Please sign in to comment.