11package api
22
33import (
4- "strings"
54 "testing"
65
76 "bridgerton.audius.co/api/dbv1"
@@ -16,8 +15,10 @@ func TestGetTrack(t *testing.T) {
1615 status , body := testGet (t , "/v1/full/tracks/eYJyn" , & trackResponse )
1716 assert .Equal (t , 200 , status )
1817
19- assert .True (t , strings .Contains (string (body ), `"title":"Culca Canyon"` ))
20- assert .True (t , strings .Contains (string (body ), `"id":"eYJyn"` ))
18+ jsonAssert (t , body , map [string ]string {
19+ "data.id" : "eYJyn" ,
20+ "data.title" : "Culca Canyon" ,
21+ })
2122}
2223
2324func TestGetTrackFollowDownloadAcess (t * testing.T ) {
@@ -26,13 +27,19 @@ func TestGetTrackFollowDownloadAcess(t *testing.T) {
2627 }
2728 // No access
2829 _ , body1 := testGet (t , "/v1/full/tracks/eYRWn" , & trackResponse )
29- assert .True (t , strings .Contains (string (body1 ), `"title":"Follow Gated Download"` ))
30- assert .True (t , strings .Contains (string (body1 ), `"access":{"stream":true,"download":false}` ))
30+ jsonAssert (t , body1 , map [string ]string {
31+ "data.title" : "Follow Gated Download" ,
32+ "data.access.stream" : "true" ,
33+ "data.access.download" : "false" ,
34+ })
3135
3236 // With access
3337 _ , body2 := testGet (t , "/v1/full/tracks/eYRWn?user_id=ELKzn" , & trackResponse )
34- assert .True (t , strings .Contains (string (body2 ), `"title":"Follow Gated Download"` ))
35- assert .True (t , strings .Contains (string (body2 ), `"access":{"stream":true,"download":true}` ))
38+ jsonAssert (t , body2 , map [string ]string {
39+ "data.title" : "Follow Gated Download" ,
40+ "data.access.stream" : "true" ,
41+ "data.access.download" : "true" ,
42+ })
3643}
3744
3845func TestGetTrackTipStreamAccess (t * testing.T ) {
@@ -41,11 +48,17 @@ func TestGetTrackTipStreamAccess(t *testing.T) {
4148 }
4249 // No access
4350 _ , body1 := testGet (t , "/v1/full/tracks/L5x7n" , & trackResponse )
44- assert .True (t , strings .Contains (string (body1 ), `"title":"Tip Gated Stream"` ))
45- assert .True (t , strings .Contains (string (body1 ), `"access":{"stream":false,"download":false}` ))
51+ jsonAssert (t , body1 , map [string ]string {
52+ "data.title" : "Tip Gated Stream" ,
53+ "data.access.stream" : "false" ,
54+ "data.access.download" : "false" ,
55+ })
4656
4757 // With access
4858 _ , body2 := testGet (t , "/v1/full/tracks/L5x7n?user_id=ELKzn" , & trackResponse )
49- assert .True (t , strings .Contains (string (body2 ), `"title":"Tip Gated Stream"` ))
50- assert .True (t , strings .Contains (string (body2 ), `"access":{"stream":true,"download":true}` ))
59+ jsonAssert (t , body2 , map [string ]string {
60+ "data.title" : "Tip Gated Stream" ,
61+ "data.access.stream" : "true" ,
62+ "data.access.download" : "true" ,
63+ })
5164}
0 commit comments