( io *iostreams.IOStreams, cfg config.IConfig, )
| 49 | } |
| 50 | |
| 51 | func newTestOptions( |
| 52 | io *iostreams.IOStreams, |
| 53 | cfg config.IConfig, |
| 54 | ) (*OpenOptions, *string, *bool) { |
| 55 | opened := new(string) |
| 56 | authed := new(bool) |
| 57 | |
| 58 | opts := &OpenOptions{ |
| 59 | IO: io, |
| 60 | config: cfg, |
| 61 | PrintFlags: cmdutil.NewPrintFlags(), |
| 62 | Authenticate: func(_ *iostreams.IOStreams, _ *dashboard.Client) (string, error) { |
| 63 | *authed = true |
| 64 | return "test-token", nil |
| 65 | }, |
| 66 | SelectApplication: func() (*dashboard.Application, error) { |
| 67 | return nil, errors.New("SelectApplication should not be called") |
| 68 | }, |
| 69 | NewDashboardClient: func(string) *dashboard.Client { |
| 70 | return &dashboard.Client{DashboardURL: "https://dashboard.algolia.com"} |
| 71 | }, |
| 72 | ListApplications: func(_ *dashboard.Client, _ string) ([]dashboard.Application, error) { |
| 73 | return []dashboard.Application{{ID: "APP123", Name: "Test"}}, nil |
| 74 | }, |
| 75 | Browser: func(u string) error { |
| 76 | *opened = u |
| 77 | return nil |
| 78 | }, |
| 79 | } |
| 80 | |
| 81 | return opts, opened, authed |
| 82 | } |
| 83 | |
| 84 | // withOutputFormat configures opts to emit structured output, as the --output |
| 85 | // flag would when parsed by cobra. |
no test coverage detected