Skip to content

Commit

Permalink
fix deleted bookamrks in unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
Monirzadeh committed Sep 24, 2024
1 parent d76009d commit 01cb7ef
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/http/routes/api/v1/bookmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestSync(t *testing.T) {
}

payloadValidWithIDs := syncPayload{
Ids: []int{3, 2},
Ids: []int{3, 2, 7},
LastSync: unixTimestampOneSecondLater,
Page: 1,
}
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestSync(t *testing.T) {

// Access the bookmarks
message := response["message"].(map[string]interface{})
deleted := message["deleted"]
deleted := message["deleted"].([]interface{})
modified := message["modified"].(map[string]interface{})
bookmarks := modified["bookmarks"].([]interface{})

Expand All @@ -238,11 +238,17 @@ func TestSync(t *testing.T) {
id := int(bookmarkMap["id"].(float64))
ids = append(ids, id)
}
// Convert deleted IDs to int
var deletedIDs []int
for _, del := range deleted {
deletedID := int(del.(float64)) // Convert each deleted ID to int
deletedIDs = append(deletedIDs, deletedID)
}

// Assert that the IDs are as expected
expectedIDs := []int{2}
deletedIDs := []int{3}
expectedDeletedIDs := []int{3, 7}
require.ElementsMatch(t, expectedIDs, ids, "bookmark IDs do not match")
require.ElementsMatch(t, deletedIDs, deleted, "deleted bookmark IDs do not match")
require.ElementsMatch(t, expectedDeletedIDs, deletedIDs, "deleted bookmark IDs do not match")
})
}

0 comments on commit 01cb7ef

Please sign in to comment.