@@ -92,11 +92,23 @@ func TestNewCmdExtension(t *testing.T) {
9292 wantErr : true ,
9393 errMsg : "specify an extension to upgrade or `--all`" ,
9494 },
95+ {
96+ name : "upgrade --all with extension name error" ,
97+ args : []string {"upgrade" , "test" , "--all" },
98+ wantErr : true ,
99+ errMsg : "cannot use `--all` with extension name" ,
100+ },
101+ {
102+ name : "upgrade --force and --dry-run error" ,
103+ args : []string {"upgrade" , "test" , "--force" , "--dry-run" },
104+ wantErr : true ,
105+ errMsg : "cannot use `--force` and `--dry-run`" ,
106+ },
95107 {
96108 name : "upgrade an extension" ,
97109 args : []string {"upgrade" , "hello" },
98110 managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
99- em .UpgradeFunc = func (name string , force bool ) error {
111+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
100112 return nil
101113 }
102114 return func (t * testing.T ) {
@@ -108,11 +120,29 @@ func TestNewCmdExtension(t *testing.T) {
108120 isTTY : true ,
109121 wantStdout : "✓ Successfully upgraded extension hello\n " ,
110122 },
123+ {
124+ name : "upgrade an extension dry run" ,
125+ args : []string {"upgrade" , "hello" , "--dry-run" },
126+ managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
127+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
128+ return nil
129+ }
130+ return func (t * testing.T ) {
131+ calls := em .UpgradeCalls ()
132+ assert .Equal (t , 1 , len (calls ))
133+ assert .Equal (t , "hello" , calls [0 ].Name )
134+ assert .False (t , calls [0 ].Force )
135+ assert .True (t , calls [0 ].DryRun )
136+ }
137+ },
138+ isTTY : true ,
139+ wantStdout : "✓ Would have upgraded extension hello\n " ,
140+ },
111141 {
112142 name : "upgrade an extension notty" ,
113143 args : []string {"upgrade" , "hello" },
114144 managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
115- em .UpgradeFunc = func (name string , force bool ) error {
145+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
116146 return nil
117147 }
118148 return func (t * testing.T ) {
@@ -127,7 +157,7 @@ func TestNewCmdExtension(t *testing.T) {
127157 name : "upgrade an up-to-date extension" ,
128158 args : []string {"upgrade" , "hello" },
129159 managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
130- em .UpgradeFunc = func (name string , force bool ) error {
160+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
131161 return upToDateError
132162 }
133163 return func (t * testing.T ) {
@@ -144,7 +174,7 @@ func TestNewCmdExtension(t *testing.T) {
144174 name : "upgrade extension error" ,
145175 args : []string {"upgrade" , "hello" },
146176 managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
147- em .UpgradeFunc = func (name string , force bool ) error {
177+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
148178 return errors .New ("oh no" )
149179 }
150180 return func (t * testing.T ) {
@@ -163,7 +193,7 @@ func TestNewCmdExtension(t *testing.T) {
163193 name : "upgrade an extension gh-prefix" ,
164194 args : []string {"upgrade" , "gh-hello" },
165195 managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
166- em .UpgradeFunc = func (name string , force bool ) error {
196+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
167197 return nil
168198 }
169199 return func (t * testing.T ) {
@@ -179,7 +209,7 @@ func TestNewCmdExtension(t *testing.T) {
179209 name : "upgrade an extension full name" ,
180210 args : []string {"upgrade" , "monalisa/gh-hello" },
181211 managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
182- em .UpgradeFunc = func (name string , force bool ) error {
212+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
183213 return nil
184214 }
185215 return func (t * testing.T ) {
@@ -195,7 +225,7 @@ func TestNewCmdExtension(t *testing.T) {
195225 name : "upgrade all" ,
196226 args : []string {"upgrade" , "--all" },
197227 managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
198- em .UpgradeFunc = func (name string , force bool ) error {
228+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
199229 return nil
200230 }
201231 return func (t * testing.T ) {
@@ -207,11 +237,29 @@ func TestNewCmdExtension(t *testing.T) {
207237 isTTY : true ,
208238 wantStdout : "✓ Successfully upgraded extensions\n " ,
209239 },
240+ {
241+ name : "upgrade all dry run" ,
242+ args : []string {"upgrade" , "--all" , "--dry-run" },
243+ managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
244+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
245+ return nil
246+ }
247+ return func (t * testing.T ) {
248+ calls := em .UpgradeCalls ()
249+ assert .Equal (t , 1 , len (calls ))
250+ assert .Equal (t , "" , calls [0 ].Name )
251+ assert .False (t , calls [0 ].Force )
252+ assert .True (t , calls [0 ].DryRun )
253+ }
254+ },
255+ isTTY : true ,
256+ wantStdout : "✓ Would have upgraded extensions\n " ,
257+ },
210258 {
211259 name : "upgrade all notty" ,
212260 args : []string {"upgrade" , "--all" },
213261 managerStubs : func (em * extensions.ExtensionManagerMock ) func (* testing.T ) {
214- em .UpgradeFunc = func (name string , force bool ) error {
262+ em .UpgradeFunc = func (name string , force , dryRun bool ) error {
215263 return nil
216264 }
217265 return func (t * testing.T ) {
0 commit comments