chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestClientDoResolvesRelativePath(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/api/v2/topics" {
|
||||
t.Fatalf("path = %q", r.URL.Path)
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte(`{"ok":true}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
resp, err := New(server.URL, server.Client()).Do(context.Background(), http.MethodGet, "/api/v2/topics", nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Do() error = %v", err)
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("status = %d", resp.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientDoRejectsEmptyPath(t *testing.T) {
|
||||
_, err := New("http://127.0.0.1:3000", nil).Do(context.Background(), http.MethodGet, "", nil, nil)
|
||||
if err == nil {
|
||||
t.Fatal("Do() expected error for empty path")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user