Skip to content

Commit

Permalink
tests: index of array does not matter
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol committed Mar 16, 2024
1 parent 91d5830 commit 4aae1d9
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions m3u/m3u_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,21 @@ http://example.com/fox
t.Fatalf("Expected %d streams, but got %d", len(expectedStreams), len(storedStreams))
}

for i, expected := range expectedStreams {
if !streamInfoEqual(storedStreams[i], expected) {
a := storedStreams[i]
b := expected
t.Errorf("Stream at index %d does not match expected content", i)
t.Errorf("%s ?= %s, %s ?= %s, %s ?= %s, %s ?= %s, %d ?= %d", a.TvgID, b.TvgID, a.Title, b.Title, a.Group, b.Group, a.LogoURL, b.LogoURL, len(a.URLs), len(b.URLs))
for _, url := range a.URLs {
t.Errorf("a: %s, %d", url.Content, url.M3UIndex)
}
for _, url := range b.URLs {
t.Errorf("b: %s, %d", url.Content, url.M3UIndex)
}
t.FailNow()
// Create a map to store expected streams for easier comparison
expectedMap := make(map[string]database.StreamInfo)
for _, expected := range expectedStreams {
expectedMap[expected.Title] = expected
}

for _, stored := range storedStreams {
expected, ok := expectedMap[stored.Title]
if !ok {
t.Errorf("Unexpected stream with Title: %s", stored.Title)
continue
}
if !streamInfoEqual(stored, expected) {
t.Errorf("Stream with Title %s does not match expected content", stored.Title)
t.Errorf("Stored: %#v, Expected: %#v", stored, expected)
}
}

Expand Down

0 comments on commit 4aae1d9

Please sign in to comment.