MCPcopy
hub / github.com/cli/cli / Test_UnarchiveRun

Function Test_UnarchiveRun

pkg/cmd/repo/unarchive/unarchive_test.go:68–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func Test_UnarchiveRun(t *testing.T) {
69 queryResponse := `{ "data": { "repository": { "id": "THE-ID","isArchived": %s} } }`
70 tests := []struct {
71 name string
72 opts UnarchiveOptions
73 httpStubs func(*httpmock.Registry)
74 prompterStubs func(*prompter.PrompterMock)
75 isTTY bool
76 wantStdout string
77 wantStderr string
78 }{
79 {
80 name: "archived repo tty",
81 wantStdout: "✓ Unarchived repository OWNER/REPO\n",
82 prompterStubs: func(pm *prompter.PrompterMock) {
83 pm.ConfirmFunc = func(p string, d bool) (bool, error) {
84 if p == "Unarchive OWNER/REPO?" {
85 return true, nil
86 }
87 return false, prompter.NoSuchPromptErr(p)
88 }
89 },
90 isTTY: true,
91 opts: UnarchiveOptions{RepoArg: "OWNER/REPO"},
92 httpStubs: func(reg *httpmock.Registry) {
93 reg.Register(
94 httpmock.GraphQL(`query RepositoryInfo\b`),
95 httpmock.StringResponse(fmt.Sprintf(queryResponse, "true")))
96 reg.Register(
97 httpmock.GraphQL(`mutation UnarchiveRepository\b`),
98 httpmock.StringResponse(`{}`))
99 },
100 },
101 {
102 name: "infer base repo",
103 wantStdout: "✓ Unarchived repository OWNER/REPO\n",
104 opts: UnarchiveOptions{},
105 prompterStubs: func(pm *prompter.PrompterMock) {
106 pm.ConfirmFunc = func(p string, d bool) (bool, error) {
107 if p == "Unarchive OWNER/REPO?" {
108 return true, nil
109 }
110 return false, prompter.NoSuchPromptErr(p)
111 }
112 },
113 isTTY: true,
114 httpStubs: func(reg *httpmock.Registry) {
115 reg.Register(
116 httpmock.GraphQL(`query RepositoryInfo\b`),
117 httpmock.StringResponse(fmt.Sprintf(queryResponse, "true")))
118 reg.Register(
119 httpmock.GraphQL(`mutation UnarchiveRepository\b`),
120 httpmock.StringResponse(`{}`))
121 },
122 },
123 {
124 name: "unarchived repo tty",
125 wantStderr: "! Repository OWNER/REPO is not archived\n",

Callers

nothing calls this directly

Calls 13

RegisterMethod · 0.95
VerifyMethod · 0.95
NoSuchPromptErrFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
FromFullNameFunction · 0.92
TestFunction · 0.92
unarchiveRunFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected