(t *testing.T)
| 94 | } |
| 95 | |
| 96 | func TestNewCmdView(t *testing.T) { |
| 97 | tests := []struct { |
| 98 | name string |
| 99 | cli string |
| 100 | wants ViewOptions |
| 101 | wantsErr bool |
| 102 | }{ |
| 103 | { |
| 104 | name: "no args", |
| 105 | cli: "", |
| 106 | wants: ViewOptions{ |
| 107 | RepoArg: "", |
| 108 | Web: false, |
| 109 | }, |
| 110 | }, |
| 111 | { |
| 112 | name: "sets repo arg", |
| 113 | cli: "some/repo", |
| 114 | wants: ViewOptions{ |
| 115 | RepoArg: "some/repo", |
| 116 | Web: false, |
| 117 | }, |
| 118 | }, |
| 119 | { |
| 120 | name: "sets web", |
| 121 | cli: "-w", |
| 122 | wants: ViewOptions{ |
| 123 | RepoArg: "", |
| 124 | Web: true, |
| 125 | }, |
| 126 | }, |
| 127 | { |
| 128 | name: "sets branch", |
| 129 | cli: "-b feat/awesome", |
| 130 | wants: ViewOptions{ |
| 131 | RepoArg: "", |
| 132 | Branch: "feat/awesome", |
| 133 | }, |
| 134 | }, |
| 135 | } |
| 136 | |
| 137 | for _, tt := range tests { |
| 138 | t.Run(tt.name, func(t *testing.T) { |
| 139 | io, _, _, _ := iostreams.Test() |
| 140 | |
| 141 | f := &cmdutil.Factory{ |
| 142 | IOStreams: io, |
| 143 | } |
| 144 | |
| 145 | // THOUGHT: this seems ripe for cmdutil. It's almost identical to the set up for the same test |
| 146 | // in gist create. |
| 147 | argv, err := shlex.Split(tt.cli) |
| 148 | assert.NoError(t, err) |
| 149 | |
| 150 | var gotOpts *ViewOptions |
| 151 | cmd := NewCmdView(f, func(opts *ViewOptions) error { |
| 152 | gotOpts = opts |
| 153 | return nil |
nothing calls this directly
no test coverage detected