── shouldSkipUpdateCheck ───────────────────────────────────────────────────
(t *testing.T)
| 21 | // ── shouldSkipUpdateCheck ─────────────────────────────────────────────────── |
| 22 | |
| 23 | func TestShouldSkipUpdateCheck(t *testing.T) { |
| 24 | tests := []struct { |
| 25 | name string |
| 26 | buildCmd func() *cobra.Command |
| 27 | want bool |
| 28 | }{ |
| 29 | { |
| 30 | name: "nil command", |
| 31 | buildCmd: func() *cobra.Command { |
| 32 | return nil |
| 33 | }, |
| 34 | want: false, |
| 35 | }, |
| 36 | { |
| 37 | name: "help command", |
| 38 | buildCmd: func() *cobra.Command { |
| 39 | return &cobra.Command{Use: "help"} |
| 40 | }, |
| 41 | want: true, |
| 42 | }, |
| 43 | { |
| 44 | name: "completion command", |
| 45 | buildCmd: func() *cobra.Command { |
| 46 | return &cobra.Command{Use: "completion"} |
| 47 | }, |
| 48 | want: true, |
| 49 | }, |
| 50 | { |
| 51 | name: "version command", |
| 52 | buildCmd: func() *cobra.Command { |
| 53 | return &cobra.Command{Use: "version"} |
| 54 | }, |
| 55 | want: true, |
| 56 | }, |
| 57 | { |
| 58 | name: "normal command", |
| 59 | buildCmd: func() *cobra.Command { |
| 60 | return &cobra.Command{Use: "status"} |
| 61 | }, |
| 62 | want: false, |
| 63 | }, |
| 64 | { |
| 65 | name: "annotated command", |
| 66 | buildCmd: func() *cobra.Command { |
| 67 | return &cobra.Command{ |
| 68 | Use: "update", |
| 69 | Annotations: map[string]string{"skipUpdateCheck": "true"}, |
| 70 | } |
| 71 | }, |
| 72 | want: true, |
| 73 | }, |
| 74 | { |
| 75 | name: "child of help command", |
| 76 | buildCmd: func() *cobra.Command { |
| 77 | parent := &cobra.Command{Use: "help"} |
| 78 | child := &cobra.Command{Use: "topic"} |
| 79 | parent.AddCommand(child) |
| 80 | return child |
nothing calls this directly
no test coverage detected