MCPcopy Create free account
hub / github.com/cli/cli / TestBranchDeleteRemote

Function TestBranchDeleteRemote

api/queries_pr_test.go:15–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

RESTFunction · 0.92
StatusStringResponseFunction · 0.92
FromFullNameFunction · 0.92
BranchDeleteRemoteFunction · 0.85
newTestClientFunction · 0.70
RunMethod · 0.65
RegisterMethod · 0.45

Tested by

no test coverage detected