(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestCreateSubscription(t *testing.T) { |
| 52 | for _, status := range []int{http.StatusCreated, http.StatusOK} { |
| 53 | t.Run(http.StatusText(status), func(t *testing.T) { |
| 54 | client, reg := newTestClient(t, "github.com") |
| 55 | var gotBody map[string]any |
| 56 | reg.Register(httpmock.REST("POST", "event-subscriptions"), func(req *http.Request) (*http.Response, error) { |
| 57 | body, err := io.ReadAll(req.Body) |
| 58 | require.NoError(t, err) |
| 59 | require.NoError(t, json.Unmarshal(body, &gotBody)) |
| 60 | return httpmock.StatusStringResponse(status, subscriptionJSON)(req) |
| 61 | }) |
| 62 | |
| 63 | sub, created, err := client.CreateSubscription(context.Background(), "https://github.com/OWNER/REPO/pull/1", |
| 64 | []string{"test.a", "test.b"}) |
| 65 | |
| 66 | require.NoError(t, err) |
| 67 | assert.Equal(t, wantSubscription, sub) |
| 68 | assert.Equal(t, status == http.StatusCreated, created) |
| 69 | assert.Equal(t, map[string]any{ |
| 70 | "resource_url": "https://github.com/OWNER/REPO/pull/1", |
| 71 | "event_types": []any{"test.a", "test.b"}, |
| 72 | }, gotBody) |
| 73 | }) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | func TestGetSubscription(t *testing.T) { |
| 78 | client, reg := newTestClient(t, "github.com") |
nothing calls this directly
no test coverage detected