(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestBranchDeleteRemote(t *testing.T) { |
| 15 | var tests = []struct { |
| 16 | name string |
| 17 | branch string |
| 18 | httpStubs func(*httpmock.Registry) |
| 19 | expectError bool |
| 20 | }{ |
| 21 | { |
| 22 | name: "success", |
| 23 | branch: "owner/branch#123", |
| 24 | httpStubs: func(reg *httpmock.Registry) { |
| 25 | reg.Register( |
| 26 | httpmock.REST("DELETE", "repos/OWNER/REPO/git/refs/heads/owner%2Fbranch%23123"), |
| 27 | httpmock.StatusStringResponse(204, "")) |
| 28 | }, |
| 29 | expectError: false, |
| 30 | }, |
| 31 | { |
| 32 | name: "error", |
| 33 | branch: "my-branch", |
| 34 | httpStubs: func(reg *httpmock.Registry) { |
| 35 | reg.Register( |
| 36 | httpmock.REST("DELETE", "repos/OWNER/REPO/git/refs/heads/my-branch"), |
| 37 | httpmock.StatusStringResponse(500, `{"message": "oh no"}`)) |
| 38 | }, |
| 39 | expectError: true, |
| 40 | }, |
| 41 | } |
| 42 | |
| 43 | for _, tt := range tests { |
| 44 | t.Run(tt.name, func(t *testing.T) { |
| 45 | http := &httpmock.Registry{} |
| 46 | if tt.httpStubs != nil { |
| 47 | tt.httpStubs(http) |
| 48 | } |
| 49 | |
| 50 | client := newTestClient(http) |
| 51 | repo, _ := ghrepo.FromFullName("OWNER/REPO") |
| 52 | |
| 53 | err := BranchDeleteRemote(client, repo, tt.branch) |
| 54 | if (err != nil) != tt.expectError { |
| 55 | t.Fatalf("unexpected result: %v", err) |
| 56 | } |
| 57 | }) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func Test_Logins(t *testing.T) { |
| 62 | rr := ReviewRequests{} |
nothing calls this directly
no test coverage detected