(t *testing.T)
| 108 | } |
| 109 | |
| 110 | func TestAPIClient_POST(t *testing.T) { |
| 111 | mock := testutil.NewMockAPI() |
| 112 | defer mock.Close() |
| 113 | |
| 114 | mock.On("POST", "/monitors", 201, `{"key":"new-mon","name":"New Monitor"}`) |
| 115 | |
| 116 | client := newTestClient(mock.Server.URL) |
| 117 | body := []byte(`{"key":"new-mon","name":"New Monitor","type":"job"}`) |
| 118 | resp, err := client.POST("/monitors", body, nil) |
| 119 | if err != nil { |
| 120 | t.Fatalf("unexpected error: %v", err) |
| 121 | } |
| 122 | |
| 123 | if resp.StatusCode != 201 { |
| 124 | t.Errorf("expected status 201, got %d", resp.StatusCode) |
| 125 | } |
| 126 | |
| 127 | req := mock.LastRequest() |
| 128 | if req.Method != "POST" { |
| 129 | t.Errorf("expected POST, got %s", req.Method) |
| 130 | } |
| 131 | if req.Body != string(body) { |
| 132 | t.Errorf("expected body %q, got %q", string(body), req.Body) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | func TestAPIClient_PUT(t *testing.T) { |
| 137 | mock := testutil.NewMockAPI() |
nothing calls this directly
no test coverage detected