MCPcopy
hub / github.com/cli/cli / TestNewCmdDelete

Function TestNewCmdDelete

pkg/cmd/cache/delete/delete_test.go:19–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestNewCmdDelete(t *testing.T) {
20 tests := []struct {
21 name string
22 cli string
23 wants DeleteOptions
24 wantsErr string
25 }{
26 {
27 name: "no arguments",
28 cli: "",
29 wantsErr: "must provide either cache id, cache key, or use --all",
30 },
31 {
32 name: "id argument",
33 cli: "123",
34 wants: DeleteOptions{Identifier: "123"},
35 },
36 {
37 name: "key argument",
38 cli: "A-Cache-Key",
39 wants: DeleteOptions{Identifier: "A-Cache-Key"},
40 },
41 {
42 name: "delete all flag",
43 cli: "--all",
44 wants: DeleteOptions{DeleteAll: true},
45 },
46 {
47 name: "delete all and succeed-on-no-caches flags",
48 cli: "--all --succeed-on-no-caches",
49 wants: DeleteOptions{DeleteAll: true, SucceedOnNoCaches: true},
50 },
51 {
52 name: "succeed-on-no-caches flag",
53 cli: "--succeed-on-no-caches",
54 wantsErr: "--succeed-on-no-caches must be used in conjunction with --all",
55 },
56 {
57 name: "succeed-on-no-caches flag and id argument",
58 cli: "--succeed-on-no-caches 123",
59 wantsErr: "--succeed-on-no-caches must be used in conjunction with --all",
60 },
61 {
62 name: "key argument and delete all flag",
63 cli: "cache-key --all",
64 wantsErr: "specify only one of cache id, cache key, or --all",
65 },
66 {
67 name: "id argument and delete all flag",
68 cli: "1 --all",
69 wantsErr: "specify only one of cache id, cache key, or --all",
70 },
71 {
72 name: "key argument with ref",
73 cli: "cache-key --ref refs/heads/main",
74 wants: DeleteOptions{Identifier: "cache-key", Ref: "refs/heads/main"},
75 },
76 {

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.80
NewCmdDeleteFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected