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

Function TestNewPauseCmd

pkg/cmd/crawler/pause/pause_test.go:15–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestNewPauseCmd(t *testing.T) {
16 tests := []struct {
17 name string
18 cli string
19 wantsErr bool
20 wantsOpts PauseOptions
21 }{
22 {
23 name: "dry run",
24 cli: "crawler-1 crawler-2 --dry-run",
25 wantsErr: false,
26 wantsOpts: PauseOptions{
27 IDs: []string{"crawler-1", "crawler-2"},
28 DryRun: true,
29 },
30 },
31 }
32
33 for _, tt := range tests {
34 t.Run(tt.name, func(t *testing.T) {
35 io, _, stdout, stderr := iostreams.Test()
36
37 f := &cmdutil.Factory{
38 IOStreams: io,
39 }
40
41 var opts *PauseOptions
42 cmd := NewPauseCmd(f, func(o *PauseOptions) error {
43 opts = o
44 return nil
45 })
46
47 args, err := shlex.Split(tt.cli)
48 require.NoError(t, err)
49 cmd.SetArgs(args)
50 _, err = cmd.ExecuteC()
51 if tt.wantsErr {
52 assert.Error(t, err)
53 return
54 }
55
56 require.NoError(t, err)
57 assert.Equal(t, "", stdout.String())
58 assert.Equal(t, "", stderr.String())
59 assert.Equal(t, tt.wantsOpts.IDs, opts.IDs)
60 assert.Equal(t, tt.wantsOpts.DryRun, opts.DryRun)
61 })
62 }
63}
64
65func Test_runPauseCmd_dryRunJSON(t *testing.T) {
66 f, out := test.NewFactory(false, nil, nil, "")

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
NewPauseCmdFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected