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

Function TestDelInteractive

cmd/del_test.go:63–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestDelInteractive(t *testing.T) {
64 is := is.New(t)
65
66 cfg := &storageMock{
67 NamesFunc: func() []string {
68 return []string{"work"}
69 },
70 DeleteProfileFunc: func(profile string) bool {
71 return true
72 },
73 SaveFunc: func(filename string) error {
74 return nil
75 },
76 }
77
78 var b bytes.Buffer
79
80 cmd := delCommand(cfg, func(_ []string, _ io.Reader, _ io.Writer) (string, error) {
81 return "work", nil
82 })
83
84 cmd.SetOut(&b)
85 cmd.SetArgs(nil)
86 err := cmd.Execute()
87
88 is.NoErr(err)
89 is.Equal(len(cfg.DeleteProfileCalls()), 1)
90 is.Equal(cfg.DeleteProfileCalls()[0].Profile, "work")
91 is.Equal(len(cfg.SaveCalls()), 1)
92 is.Equal(trim(b.String()), "Successfully removed `work` profile.")
93}
94
95func TestDelInteractiveCancelled(t *testing.T) {
96 is := is.New(t)

Callers

nothing calls this directly

Calls 5

DeleteProfileCallsMethod · 0.95
SaveCallsMethod · 0.95
delCommandFunction · 0.85
trimFunction · 0.85
ExecuteMethod · 0.80

Tested by

no test coverage detected