-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
466 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package spotify | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestGetAChapter(t *testing.T) { | ||
client, server := testClientFile(http.StatusOK, "get_a_chapter.txt") | ||
defer server.Close() | ||
|
||
res, err := client.GetAChapter("0D5wENdkdwbqlrHoaJ9g29", "ES") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
fmt.Println(res) | ||
|
||
if res == nil { | ||
t.Error("Expected response") | ||
} else { | ||
if res.ID != "0D5wENdkdwbqlrHoaJ9g29" { | ||
t.Errorf("Expected %s, got %s", "0D5wENdkdwbqlrHoaJ9g29", res.ID) | ||
} | ||
} | ||
} | ||
|
||
func TestGetSeveralChapters(t *testing.T) { | ||
client, server := testClientFile(http.StatusOK, "get_several_chapters.txt") | ||
defer server.Close() | ||
|
||
res, err := client.GetSeveralChapters([]string{"0IsXVP0JmcB2adSE338GkK", "3ZXb8FKZGU0EHALYX6uCzU", "0D5wENdkdwbqlrHoaJ9g29"}, "ES") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if res != nil { | ||
if len(res.Chapters) != 3 { | ||
t.Errorf("Expected %d, got %d", 3, len(res.Chapters)) | ||
} | ||
} else { | ||
t.Error("Expected response") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"restrictions": { | ||
"reason": "payment_required" | ||
}, | ||
"id": "0D5wENdkdwbqlrHoaJ9g29", | ||
"description": "", | ||
"chapter_number": 0, | ||
"duration_ms": 42841, | ||
"explicit": false, | ||
"images": [ | ||
{ | ||
"height": 640, | ||
"url": "https://i.scdn.co/image/ab676663000022a87e6216b6bf7861e7b8ceca4d", | ||
"width": 640 | ||
}, | ||
{ | ||
"height": 300, | ||
"url": "https://i.scdn.co/image/ab6766630000db5b7e6216b6bf7861e7b8ceca4d", | ||
"width": 300 | ||
}, | ||
{ | ||
"height": 64, | ||
"url": "https://i.scdn.co/image/ab6766630000703b7e6216b6bf7861e7b8ceca4d", | ||
"width": 64 | ||
} | ||
], | ||
"languages": [ | ||
"" | ||
], | ||
"name": "Introduction", | ||
"audio_preview_url": null, | ||
"release_date": "1970-01-01", | ||
"release_date_precision": "day", | ||
"resume_point": { | ||
"fully_played": false, | ||
"resume_position_ms": 0 | ||
}, | ||
"is_playable": false, | ||
"html_description": "", | ||
"audiobook": { | ||
"authors": [ | ||
{ | ||
"name": "Cixin Liu" | ||
} | ||
], | ||
"chapters": { | ||
"href": null, | ||
"items": [], | ||
"limit": 0, | ||
"next": null, | ||
"offset": 0, | ||
"previous": null, | ||
"total": null | ||
}, | ||
"copyrights": [], | ||
"description": "Author(s): Cixin Liu\nNarrator(s): Luke Daniels\n\n<p><i>The Three-Body Problem </i>is the first chance for English-speaking readers to experience the Hugo Award-winning phenomenon from China's most beloved science fiction author, Liu Cixin.</p><p>Set against the backdrop of China's Cultural Revolution, a secret military project sends signals into space to establish contact with aliens. An alien civilization on the brink of destruction captures the signal and plans to invade Earth. </P><P>Meanwhile, on Earth, different camps start forming, planning to either welcome the superior beings and help them take over a world seen as corrupt, or to fight against the invasion. The result is a science fiction masterpiece of enormous scope and vision.</p></p><P>A Macmillan Audio production.</P>", | ||
"edition": null, | ||
"explicit": false, | ||
"external_urls": { | ||
"spotify": "https://open.spotify.com/show/1lxwPzRvQTVbwwoEdxyt6b" | ||
}, | ||
"href": "https://api.spotify.com/v1/audiobooks/1lxwPzRvQTVbwwoEdxyt6b", | ||
"html_description": "Author(s): Cixin Liu<br/>Narrator(s): Luke Daniels<br/><p><i>The Three-Body Problem </i>is the first chance for English-speaking readers to experience the Hugo Award-winning phenomenon from China's most beloved science fiction author, Liu Cixin.</p><p>Set against the backdrop of China's Cultural Revolution, a secret military project sends signals into space to establish contact with aliens. An alien civilization on the brink of destruction captures the signal and plans to invade Earth. </P><P>Meanwhile, on Earth, different camps start forming, planning to either welcome the superior beings and help them take over a world seen as corrupt, or to fight against the invasion. The result is a science fiction masterpiece of enormous scope and vision.</p></p><P>A Macmillan Audio production.</P>", | ||
"id": "1lxwPzRvQTVbwwoEdxyt6b", | ||
"images": [ | ||
{ | ||
"height": 640, | ||
"url": "https://i.scdn.co/image/ab676663000022a87e6216b6bf7861e7b8ceca4d", | ||
"width": 640 | ||
}, | ||
{ | ||
"height": 300, | ||
"url": "https://i.scdn.co/image/ab6766630000db5b7e6216b6bf7861e7b8ceca4d", | ||
"width": 300 | ||
}, | ||
{ | ||
"height": 64, | ||
"url": "https://i.scdn.co/image/ab6766630000703b7e6216b6bf7861e7b8ceca4d", | ||
"width": 64 | ||
} | ||
], | ||
"languages": [ | ||
"English" | ||
], | ||
"media_type": "audio", | ||
"name": "The Three-Body Problem", | ||
"narrators": [ | ||
{ | ||
"name": "Luke Daniels" | ||
} | ||
], | ||
"publisher": "Macmillan Audio", | ||
"total_chapters": null, | ||
"type": "audiobook", | ||
"uri": "spotify:show:1lxwPzRvQTVbwwoEdxyt6b" | ||
}, | ||
"type": "chapter", | ||
"uri": "spotify:episode:0D5wENdkdwbqlrHoaJ9g29", | ||
"href": "https://api.spotify.com/v1/chapters/0D5wENdkdwbqlrHoaJ9g29", | ||
"external_urls": { | ||
"spotify": "https://open.spotify.com/episode/0D5wENdkdwbqlrHoaJ9g29" | ||
} | ||
} |
Oops, something went wrong.