MCPcopy Create free account
hub / github.com/algolia/cli / newTestOptions

Function newTestOptions

pkg/cmd/open/open_test.go:51–82  ·  view source on GitHub ↗
(
	io *iostreams.IOStreams,
	cfg config.IConfig,
)

Source from the content-addressed store, hash-verified

49}
50
51func 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.

Calls 1

NewPrintFlagsFunction · 0.92

Tested by

no test coverage detected