Add tests for playlist.

This commit is contained in:
Kavin 2022-04-06 04:14:16 +01:00
parent b049848e79
commit 797a621b51
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
3 changed files with 21 additions and 3 deletions

View file

@ -965,9 +965,12 @@ public class ResponseHelper {
s.save(playlist);
s.getTransaction().begin();
s.getTransaction().commit();
}
return Constants.mapper.writeValueAsBytes(new AcceptedResponse());
ObjectNode response = Constants.mapper.createObjectNode();
response.put("playlistId", String.valueOf(playlist.getPlaylistId()));
return Constants.mapper.writeValueAsBytes(response);
}
}
public static byte[] playlistsResponse(String session) throws IOException {

View file

@ -38,7 +38,8 @@ public class Playlist {
@Column(name = "thumbnail", length = 300)
private String thumbnail;
@Column(name = "owner", nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "owner")
private User owner;
@ElementCollection(fetch = FetchType.LAZY)

View file

@ -84,3 +84,17 @@ sleep 2
# Check Feed
curl ${CURLOPTS[@]} $HOST/feed -G --data-urlencode "authToken=$AUTH_TOKEN" || exit 1
PLAYLIST_NAME=$(openssl rand -hex 6)
# Create a Playlist
curl ${CURLOPTS[@]} $HOST/user/playlists/create -X POST -H "Content-Type: application/json" -H "Authorization: $AUTH_TOKEN" -d $(jq -n --compact-output --arg name "$PLAYLIST_NAME" '{"name": $name}') || exit 1
# See created playlists
curl ${CURLOPTS[@]} $HOST/user/playlists -H "Authorization: $AUTH_TOKEN" || exit 1
# Get Playlist ID
PLAYLIST_ID=$(curl -s -o - -f $HOST/user/playlists -H "Authorization: $AUTH_TOKEN" | jq -r ".[0].id") || exit 1
# Playlist Test
curl ${CURLOPTS[@]} $HOST/playlists/$PLAYLIST_ID || exit 1