MCPcopy
hub / github.com/cli/cli / Test_deleteAssetRun

Function Test_deleteAssetRun

pkg/cmd/release/delete-asset/delete_asset_test.go:101–201  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

99}
100
101func Test_deleteAssetRun(t *testing.T) {
102 tests := []struct {
103 name string
104 isTTY bool
105 opts DeleteAssetOptions
106 prompterStubs func(*prompter.PrompterMock)
107 wantErr string
108 wantStdout string
109 wantStderr string
110 }{
111 {
112 name: "interactive confirm",
113 isTTY: true,
114 opts: DeleteAssetOptions{
115 TagName: "v1.2.3",
116 AssetName: "test-asset",
117 },
118 prompterStubs: func(pm *prompter.PrompterMock) {
119 pm.ConfirmFunc = func(p string, d bool) (bool, error) {
120 if p == "Delete asset test-asset in release v1.2.3 in OWNER/REPO?" {
121 return true, nil
122 }
123 return false, prompter.NoSuchPromptErr(p)
124 }
125 },
126 wantStdout: ``,
127 wantStderr: "✓ Deleted asset test-asset from release v1.2.3\n",
128 },
129 {
130 name: "skipping confirmation",
131 isTTY: true,
132 opts: DeleteAssetOptions{
133 TagName: "v1.2.3",
134 SkipConfirm: true,
135 AssetName: "test-asset",
136 },
137 wantStdout: ``,
138 wantStderr: "✓ Deleted asset test-asset from release v1.2.3\n",
139 },
140 {
141 name: "non-interactive",
142 isTTY: false,
143 opts: DeleteAssetOptions{
144 TagName: "v1.2.3",
145 SkipConfirm: false,
146 AssetName: "test-asset",
147 },
148 wantStdout: ``,
149 wantStderr: ``,
150 },
151 }
152 for _, tt := range tests {
153 t.Run(tt.name, func(t *testing.T) {
154 ios, _, stdout, stderr := iostreams.Test()
155 ios.SetStdoutTTY(tt.isTTY)
156 ios.SetStdinTTY(tt.isTTY)
157 ios.SetStderrTTY(tt.isTTY)
158

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RegisterMethod · 0.95
NoSuchPromptErrFunction · 0.92
TestFunction · 0.92
StubFetchReleaseFunction · 0.92
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
FromFullNameFunction · 0.92
deleteAssetRunFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80

Tested by

no test coverage detected