Compare commits

...

2 commits

Author SHA1 Message Date
f7132c06fc
Fix route tests 2025-02-14 06:26:38 +10:00
034c4e1088
Add documentation around DB lookup semantics 2025-02-14 06:26:16 +10:00
2 changed files with 7 additions and 5 deletions

View file

@ -72,7 +72,9 @@ func (env *Env) getArtistByName(c *gin.Context) {
}
// Lookup this name in the DB and return any ArtistProfile objects
// This is case insensitive on sqlite
// NOTE: This is case insensitive on sqlite
// NOTE: However unicode is treated case sensitive due to very difficult conversions for some languages/characters
// NOTE: In future better DBs with unicode support such as postgres should be used
var artistProfiles []ArtistProfile
dbResult := env.db.Where("name LIKE ?", fmt.Sprintf("%%%s%%", artistName)).Preload("Genres").Find(&artistProfiles)
if dbResult.Error != nil {

View file

@ -36,13 +36,13 @@ func TestGetArtistByIDRoute(t *testing.T) {
// Dynamic data is hard to test so here we validate JSON response
// And we check known fields which are not likely to change
// We then check that the DB was updated correctly just to be sure
var spotifyResp SpotifyResponse
err := json.NewDecoder(w.Body).Decode(&spotifyResp)
var resp ArtistProfile
err := json.NewDecoder(w.Body).Decode(&resp)
if err != nil {
assert.Fail(t, fmt.Sprintf("Could not validate and parse JSON response into SpotifyResponse struct: %s", err.Error()))
}
assert.Equal(t, "0TnOYISbd1XYRBk9myaseg", spotifyResp.ID)
assert.Equal(t, "Pitbull", spotifyResp.Name)
assert.Equal(t, "0TnOYISbd1XYRBk9myaseg", resp.SpotifyID)
assert.Equal(t, "Pitbull", resp.Name)
var artist ArtistProfile
dbResult := env.db.Take(&artist)