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

Function Test_getRun

pkg/cmd/variable/get/get_test.go:107–298  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func Test_getRun(t *testing.T) {
108 tf, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")
109
110 tests := []struct {
111 name string
112 opts *GetOptions
113 host string
114 httpStubs func(*httpmock.Registry)
115 jsonFields []string
116 wantOut string
117 wantErr error
118 }{
119 {
120 name: "getting repo variable",
121 opts: &GetOptions{
122 VariableName: "VARIABLE_ONE",
123 },
124 host: "github.com",
125 httpStubs: func(reg *httpmock.Registry) {
126 reg.Register(httpmock.WithHost(httpmock.REST("GET", "repos/owner/repo/actions/variables/VARIABLE_ONE"), "api.github.com"),
127 httpmock.JSONResponse(shared.Variable{
128 Value: "repo_var",
129 }))
130 },
131 wantOut: "repo_var\n",
132 },
133 {
134 name: "getting GHES repo variable",
135 opts: &GetOptions{
136 VariableName: "VARIABLE_ONE",
137 },
138 host: "example.com",
139 httpStubs: func(reg *httpmock.Registry) {
140 reg.Register(httpmock.WithHost(httpmock.REST("GET", "api/v3/repos/owner/repo/actions/variables/VARIABLE_ONE"), "example.com"),
141 httpmock.JSONResponse(shared.Variable{
142 Value: "repo_var",
143 }))
144 },
145 wantOut: "repo_var\n",
146 },
147 {
148 name: "getting org variable",
149 opts: &GetOptions{
150 OrgName: "TestOrg",
151 VariableName: "VARIABLE_ONE",
152 },
153 host: "github.com",
154 httpStubs: func(reg *httpmock.Registry) {
155 reg.Register(httpmock.REST("GET", "orgs/TestOrg/actions/variables/VARIABLE_ONE"),
156 httpmock.JSONResponse(shared.Variable{
157 Value: "org_var",
158 }))
159 },
160 wantOut: "org_var\n",
161 },
162 {
163 name: "getting env variable",
164 opts: &GetOptions{

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
WithHostFunction · 0.92
RESTFunction · 0.92
JSONResponseFunction · 0.92
StatusStringResponseFunction · 0.92
TestFunction · 0.92
FromFullNameWithHostFunction · 0.92
NewBlankConfigFunction · 0.92
NewJSONExporterFunction · 0.92
SetStdoutTTYMethod · 0.80
SetFieldsMethod · 0.80

Tested by

no test coverage detected