MCPcopy Create free account
hub / github.com/github/gh-aw / TestSecretSetClientOptions

Function TestSecretSetClientOptions

pkg/cli/secret_set_command_test.go:170–210  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

168}
169
170func TestSecretSetClientOptions(t *testing.T) {
171 t.Run("defaults include timeout", func(t *testing.T) {
172 opts := secretSetClientOptions("")
173 if opts.Host != "" {
174 t.Fatalf("expected empty host, got %q", opts.Host)
175 }
176 if opts.Timeout != constants.DefaultHTTPClientTimeout {
177 t.Fatalf("expected timeout %s, got %s", constants.DefaultHTTPClientTimeout, opts.Timeout)
178 }
179 })
180
181 t.Run("normalizes host when api-url is provided", func(t *testing.T) {
182 opts := secretSetClientOptions("https://ghe.example.com")
183 if opts.Host != "ghe.example.com" {
184 t.Fatalf("expected host ghe.example.com, got %q", opts.Host)
185 }
186 if opts.Timeout != constants.DefaultHTTPClientTimeout {
187 t.Fatalf("expected timeout %s, got %s", constants.DefaultHTTPClientTimeout, opts.Timeout)
188 }
189 })
190
191 t.Run("strips API path from api-url", func(t *testing.T) {
192 opts := secretSetClientOptions("https://ghe.example.com/api/v3")
193 if opts.Host != "ghe.example.com" {
194 t.Fatalf("expected host ghe.example.com, got %q", opts.Host)
195 }
196 if opts.Timeout != constants.DefaultHTTPClientTimeout {
197 t.Fatalf("expected timeout %s, got %s", constants.DefaultHTTPClientTimeout, opts.Timeout)
198 }
199 })
200
201 t.Run("maps api.github.com to github.com", func(t *testing.T) {
202 opts := secretSetClientOptions("https://api.github.com")
203 if opts.Host != "github.com" {
204 t.Fatalf("expected host github.com, got %q", opts.Host)
205 }
206 if opts.Timeout != constants.DefaultHTTPClientTimeout {
207 t.Fatalf("expected timeout %s, got %s", constants.DefaultHTTPClientTimeout, opts.Timeout)
208 }
209 })
210}

Callers

nothing calls this directly

Calls 2

secretSetClientOptionsFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected