This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
go-discogs/releases_test.go

31 lines
661 B
Go
Raw Permalink Normal View History

2016-03-10 14:25:55 +00:00
package discogs
import (
2018-02-20 17:00:24 +00:00
"io"
"net/http"
"net/http/httptest"
2016-03-10 14:25:55 +00:00
"testing"
)
2018-02-20 17:00:24 +00:00
func ReleaseServer(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
io.WriteString(w, `{"title":"Elephant Riddim"}`)
}
func TestReleaseServiceRelease(t *testing.T) {
2016-03-10 14:25:55 +00:00
expectedTitle := "Elephant Riddim"
2018-02-20 17:00:24 +00:00
ts := httptest.NewServer(http.HandlerFunc(ReleaseServer))
defer ts.Close()
2018-03-12 16:30:58 +00:00
d := initDiscogsClient(t, &Options{URL: ts.URL})
release, err := d.Release.Release(8138518)
2018-02-20 17:00:24 +00:00
if err != nil {
2018-03-12 16:30:58 +00:00
t.Fatalf("failed to get release: %s", err)
2018-02-20 17:00:24 +00:00
}
2016-03-10 14:25:55 +00:00
2018-03-12 16:30:58 +00:00
if release.Title != expectedTitle {
t.Fatalf("release title got=%s want=%s ", expectedTitle, release.Title)
}
2016-03-10 14:25:55 +00:00
}