MCPcopy
hub / github.com/cli/cli / TestDeleteRun

Function TestDeleteRun

pkg/cmd/alias/delete/delete_test.go:87–188  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestDeleteRun(t *testing.T) {
88 tests := []struct {
89 name string
90 config string
91 isTTY bool
92 opts *DeleteOptions
93 wantAliases map[string]string
94 wantStdout string
95 wantStderr string
96 wantErrMsg string
97 }{
98 {
99 name: "delete alias",
100 config: heredoc.Doc(`
101 aliases:
102 il: issue list
103 co: pr checkout
104 `),
105 isTTY: true,
106 opts: &DeleteOptions{
107 Name: "co",
108 All: false,
109 },
110 wantAliases: map[string]string{
111 "il": "issue list",
112 },
113 wantStderr: "✓ Deleted alias co; was pr checkout\n",
114 },
115 {
116 name: "delete all aliases",
117 config: heredoc.Doc(`
118 aliases:
119 il: issue list
120 co: pr checkout
121 `),
122 isTTY: true,
123 opts: &DeleteOptions{
124 All: true,
125 },
126 wantAliases: map[string]string{},
127 wantStderr: "✓ Deleted alias co; was pr checkout\n✓ Deleted alias il; was issue list\n",
128 },
129 {
130 name: "delete alias that does not exist",
131 config: heredoc.Doc(`
132 aliases:
133 il: issue list
134 co: pr checkout
135 `),
136 isTTY: true,
137 opts: &DeleteOptions{
138 Name: "unknown",
139 },
140 wantAliases: map[string]string{
141 "il": "issue list",
142 "co": "pr checkout",
143 },
144 wantErrMsg: "no such alias unknown",

Callers

nothing calls this directly

Calls 12

TestFunction · 0.92
NewFromStringFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
WriteCallsMethod · 0.80
EqualMethod · 0.80
deleteRunFunction · 0.70
RunMethod · 0.65
AllMethod · 0.65
AliasesMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected