Skip to content

Commit

Permalink
radio: fix SongEqualTo test
Browse files Browse the repository at this point in the history
Due to how big the Song struct is now after including LastPlayedBy the
gopter generation fails generating strings too much. Instead we limit
generation of specific length strings to only the Song fields and not
DatabaseTrack and User fields. This avoids the limit hitting.
  • Loading branch information
Wessie committed Feb 22, 2024
1 parent 1d8552d commit 6758e59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions radio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ func TestSongEqualTo(t *testing.T) {
tp.MinSuccessfulTests = 500
a := arbitrary.DefaultArbitraries()
p := gopter.NewProperties(tp)
ab := arbitrary.DefaultArbitraries()

// we only want songs with actual string data to compare against
a.RegisterGen(gen.UnicodeString(unicode.Katakana).SuchThat(func(s string) bool { return len(s) > 5 }))
a.RegisterGen(ab.GenForType(reflect.TypeOf(&User{})))
a.RegisterGen(ab.GenForType(reflect.TypeOf(&DatabaseTrack{})))

p.Property("song a != b",
a.ForAll(func(a, b Song) bool {
Expand Down
1 change: 1 addition & 0 deletions website/api/php/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func (a *API) getCanRequest(w http.ResponseWriter, r *http.Request) {
return
}

// TODO(wessie): check if this is the right identifier
identifier := r.RemoteAddr
userLastRequest, err := a.storage.Request(r.Context()).LastRequest(identifier)
if err != nil {
Expand Down

0 comments on commit 6758e59

Please sign in to comment.