MCPcopy
hub / github.com/dnote/dnote / RunDnoteCmd

Function RunDnoteCmd

pkg/cli/testutils/main.go:147–167  ·  view source on GitHub ↗

RunDnoteCmd runs a dnote command

(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg ...string)

Source from the content-addressed store, hash-verified

145
146// RunDnoteCmd runs a dnote command
147func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg ...string) string {
148 t.Logf("running: %s %s", binaryName, strings.Join(arg, " "))
149
150 cmd, stderr, stdout, err := NewDnoteCmd(opts, binaryName, arg...)
151 if err != nil {
152 t.Logf("\n%s", stdout)
153 t.Fatal(errors.Wrap(err, "getting command").Error())
154 }
155
156 cmd.Env = append(cmd.Env, "DNOTE_DEBUG=1")
157
158 if err := cmd.Run(); err != nil {
159 t.Logf("\n%s", stdout)
160 t.Fatal(errors.Wrapf(err, "running command %s", stderr.String()))
161 }
162
163 // Print stdout if and only if test fails later
164 t.Logf("\n%s", stdout)
165
166 return stdout.String()
167}
168
169// WaitDnoteCmd runs a dnote command and passes stdout to the callback.
170func WaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.Reader, io.WriteCloser) error, binaryName string, arg ...string) (string, error) {

Callers 8

TestInitFunction · 0.92
TestAddNoteFunction · 0.92
TestEditNoteFunction · 0.92
TestEditBookFunction · 0.92
TestRemoveNoteFunction · 0.92
TestRemoveBookFunction · 0.92
TestDBPathFlagFunction · 0.92
TestViewFunction · 0.92

Calls 2

NewDnoteCmdFunction · 0.85
ErrorMethod · 0.45

Tested by 8

TestInitFunction · 0.74
TestAddNoteFunction · 0.74
TestEditNoteFunction · 0.74
TestEditBookFunction · 0.74
TestRemoveNoteFunction · 0.74
TestRemoveBookFunction · 0.74
TestDBPathFlagFunction · 0.74
TestViewFunction · 0.74