newOpts builds CreateOptions wired to the stub server, defaulting to JSON output.
( t *testing.T, srv *createServer, isTTY bool, )
| 235 | |
| 236 | // newOpts builds CreateOptions wired to the stub server, defaulting to JSON output. |
| 237 | func newOpts( |
| 238 | t *testing.T, |
| 239 | srv *createServer, |
| 240 | isTTY bool, |
| 241 | ) (*CreateOptions, *test.CmdInOut, *string) { |
| 242 | t.Helper() |
| 243 | seedToken(t) |
| 244 | |
| 245 | f, out := test.NewFactory(isTTY, nil, nil, "") |
| 246 | opened := new(string) |
| 247 | opts := &CreateOptions{ |
| 248 | IO: f.IOStreams, |
| 249 | Config: f.Config, |
| 250 | Name: "My First Application", |
| 251 | Region: "CA", |
| 252 | nameProvided: true, |
| 253 | PrintFlags: newPrintFlags("json"), |
| 254 | NewDashboardClient: func(string) *dashboard.Client { |
| 255 | c := dashboard.NewClientWithHTTPClient("test", srv.Client()) |
| 256 | c.APIURL = srv.URL |
| 257 | c.DashboardURL = "https://dashboard.algolia.com" |
| 258 | return c |
| 259 | }, |
| 260 | Browser: func(url string) error { |
| 261 | *opened = url |
| 262 | return nil |
| 263 | }, |
| 264 | } |
| 265 | return opts, out, opened |
| 266 | } |
| 267 | |
| 268 | func TestRun_FreeNonInteractive(t *testing.T) { |
| 269 | srv := newServer(t, `{"has_payment_method": false}`) |
no test coverage detected