Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions test/clj_spotify/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
(testing "Conversion from string to clojure map"
(is (= tf/correct-map (sptfy/response-to-map tf/correctly-formatted-response))))
(testing "Missing body tag in response."
(is (= (tf/nullpointer-error-map tf/missing-body-tag-response) (sptfy/response-to-map tf/missing-body-tag-response))))
(let [actual (sptfy/response-to-map tf/missing-body-tag-response)]
(is (or (= (tf/nullpointer-error-map tf/missing-body-tag-response) actual)
;; Java 14 and above have extended error messages for NPE
(= (tf/nullpointer-error-map tf/missing-body-tag-response "Cannot invoke \"String.length()\" because \"s\" is null") actual)))))
(testing "Malformed json syntax in string."
(is (= (tf/json-missing-key-error-map tf/malformed-json-response) (sptfy/response-to-map tf/malformed-json-response)))))

Expand Down Expand Up @@ -66,14 +69,6 @@
(testing "Get spotify information about an artists top tracks, due to ever changing data, only verify a status 200 response."
(is (= 200 (:status (meta (sptfy/get-an-artists-top-tracks {:id "0TnOYISbd1XYRBk9myaseg" :country "ES" } util/spotify-oauth-token)))))))

(deftest test-get-an-artists-related-artists
(testing "Get spotify information about similar artists, due to ever changing data, only verify a status 200 response."
(is (= 200 (:status (meta (sptfy/get-an-artists-related-artists {:id "5ZKMPRDHc7qElVJFh3uRqB"} util/spotify-oauth-token)))))))

(deftest test-get-a-list-of-featured-playlists
(testing "Get a list of spotify featured playlists, due to the data changing according to the time of day, only verify status 200 in response."
(is (= 200 (:status (meta (sptfy/get-a-list-of-featured-playlists {:country "US" :timestamp "2014-10-23T07:00:00"} util/spotify-oauth-token)))))))

(deftest test-get-a-list-of-new-releases
(testing "Get a list of new releases, due to ever changing data, only verify a status 200 response."
(is (= 200 (:status (meta (sptfy/get-a-list-of-new-releases {:country "SE" :limit 2} util/spotify-oauth-token)))))))
Expand All @@ -86,10 +81,6 @@
(testing "Get a spotify category and verify the json data to be equal to test data in category.json"
(generate-test ( sptfy/get-a-category {:category_id "dinner" :locale "sv_SE" :country "SE"} util/spotify-oauth-token) tf/category-file)))

(deftest test-get-a-categorys-playlists
(testing "Get a spotify category's playlist, due to ever changing data, only verify a status 200 response."
(is (= 200 (:status (meta (sptfy/get-a-categorys-playlists {:category_id "dinner" :country "SE" :limit 10 :offset 5} util/spotify-oauth-token)))))))

(deftest test-get-a-playlist
(testing "Get a spotify playlist and verify the json data to be equal to test data in user-playlist.json"
(generate-test (sptfy/get-a-playlist {:user_id "elkalel" :playlist_id "5X6O7Wb8y3we9VzYTT9l64" :market "SE"} util/spotify-oauth-token) tf/playlist-file)))
Expand Down
3 changes: 1 addition & 2 deletions test/clj_spotify/test-data/get-a-track.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,5 @@
"track_number" : 1,
"type" : "track",
"uri" : "spotify:track:1zHlj4dQ8ZAtrayhuDDmkY",
"is_local" : 0,
"available_markets" : 0
"is_local" : 0
}
4 changes: 3 additions & 1 deletion test/clj_spotify/test_fixtures.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@

(def malformed-json-response {:body "{\"test-key\": \"test-value\", \"test-map\" : {\"a\": \"a\"}, \"test-vector\" : [1 2 3], \"test-null\" : }"})

(defn nullpointer-error-map [response] {:error {:status "NullPointerException", :message nil, :response response}})
(defn nullpointer-error-map
([response] (nullpointer-error-map response nil))
([response message] {:error {:status "NullPointerException", :message message, :response response}}))

(defn json-missing-key-error-map [response]
{:error {:status "Exception", :message "JSON error (key missing value in object)", :response response}})
Expand Down