MCPcopy Index your code
hub / github.com/cli/cli / TestBranchDeleteRemote

Function TestBranchDeleteRemote

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

Source from the content-addressed store, hash-verified

12)
13
14func 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
61func Test_Logins(t *testing.T) {
62 rr := ReviewRequests{}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected