Compare commits
2 commits
d56b21a3d1
...
f7132c06fc
Author | SHA1 | Date | |
---|---|---|---|
f7132c06fc | |||
034c4e1088 |
2 changed files with 7 additions and 5 deletions
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue