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
2018-03-12 19:30:58 +03:00

31 lines
661 B
Go

package discogs
import (
"io"
"net/http"
"net/http/httptest"
"testing"
)
func ReleaseServer(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
io.WriteString(w, `{"title":"Elephant Riddim"}`)
}
func TestReleaseServiceRelease(t *testing.T) {
expectedTitle := "Elephant Riddim"
ts := httptest.NewServer(http.HandlerFunc(ReleaseServer))
defer ts.Close()
d := initDiscogsClient(t, &Options{URL: ts.URL})
release, err := d.Release.Release(8138518)
if err != nil {
t.Fatalf("failed to get release: %s", err)
}
if release.Title != expectedTitle {
t.Fatalf("release title got=%s want=%s ", expectedTitle, release.Title)
}
}