MCPcopy Create free account
hub / github.com/dotzero/git-profile / TestAddInteractiveAbortDoesNotPrintSaveError

Function TestAddInteractiveAbortDoesNotPrintSaveError

cmd/add_test.go:151–187  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

149}
150
151func TestAddInteractiveAbortDoesNotPrintSaveError(t *testing.T) {
152 is := is.New(t)
153
154 cfg := &storageMock{
155 StoreFunc: func(profile string, key string, value string) {
156 t.Fatalf("Store should not be called")
157 },
158 SaveFunc: func(filename string) error {
159 t.Fatalf("Save should not be called")
160 return nil
161 },
162 }
163
164 var (
165 out bytes.Buffer
166 errOut bytes.Buffer
167 )
168
169 cmd := addCommand(
170 cfg,
171 func(_ io.Reader, _ io.Writer) (string, error) {
172 return "", huh.ErrUserAborted
173 },
174 func(_ ui.ProfileFormData, _ io.Reader, _ io.Writer) (ui.ProfileFormData, error) {
175 t.Fatalf("PromptProfileFields should not be called")
176 return ui.ProfileFormData{}, nil
177 },
178 )
179 cmd.SetOut(&out)
180 cmd.SetErr(&errOut)
181 cmd.SetArgs(nil)
182
183 err := cmd.Execute()
184
185 is.NoErr(err)
186 is.Equal(trim(errOut.String()), "Interactive add cancelled.")
187}

Callers

nothing calls this directly

Calls 3

addCommandFunction · 0.85
trimFunction · 0.85
ExecuteMethod · 0.80

Tested by

no test coverage detected