Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resell V2 Users: test HTTP methods #34

Merged
merged 1 commit into from
Apr 12, 2018
Merged
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
16 changes: 16 additions & 0 deletions selvpcclient/resell/v2/users/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func TestListUsers(t *testing.T) {
testEnv.Mux.HandleFunc("/resell/v2/users", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, TestListUsersResponseRaw)

if r.Method != http.MethodGet {
t.Fatalf("expected %s method but got %s", http.MethodGet, r.Method)
}
})

ctx := context.Background()
Expand Down Expand Up @@ -47,6 +51,10 @@ func TestListUsersSingle(t *testing.T) {
testEnv.Mux.HandleFunc("/resell/v2/users", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, TestListUsersSingleUserResponseRaw)

if r.Method != http.MethodGet {
t.Fatalf("expected %s method but got %s", http.MethodGet, r.Method)
}
})

ctx := context.Background()
Expand All @@ -70,6 +78,10 @@ func TestCreateUser(t *testing.T) {
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, TestCreateUserResponseRaw)

if r.Method != http.MethodPost {
t.Fatalf("expected %s method but got %s", http.MethodPost, r.Method)
}

b, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Errorf("unable to read the request body: %v", err)
Expand Down Expand Up @@ -114,6 +126,10 @@ func TestUpdateUser(t *testing.T) {
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, TestUpdateUserResponseRaw)

if r.Method != http.MethodPatch {
t.Fatalf("expected %s method but got %s", http.MethodPatch, r.Method)
}

b, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Errorf("unable to read the request body: %v", err)
Expand Down