@@ -18,6 +18,7 @@ func TestCreateAppVersionCommand(t *testing.T) {
1818 tests := []struct {
1919 name string
2020 request * model.CreateAppVersionRequest
21+ dryRun bool
2122 shouldError bool
2223 errorMessage string
2324 }{
@@ -36,10 +37,28 @@ func TestCreateAppVersionCommand(t *testing.T) {
3637 }},
3738 },
3839 },
40+ dryRun : false ,
41+ },
42+ {
43+ name : "success with dry-run" ,
44+ request : & model.CreateAppVersionRequest {
45+ ApplicationKey : "app-key" ,
46+ Version : "1.0.0" ,
47+ Sources : & model.CreateVersionSources {
48+ Packages : []model.CreateVersionPackage {{
49+ Type : "type" ,
50+ Name : "name" ,
51+ Version : "1.0.0" ,
52+ Repository : "repo" ,
53+ }},
54+ },
55+ },
56+ dryRun : true ,
3957 },
4058 {
4159 name : "context error" ,
4260 request : & model.CreateAppVersionRequest {ApplicationKey : "app-key" , Version : "1.0.0" , Draft : false , Sources : & model.CreateVersionSources {Packages : []model.CreateVersionPackage {{Type : "type" , Name : "name" , Version : "1.0.0" , Repository : "repo" }}}},
61+ dryRun : false ,
4362 shouldError : true ,
4463 errorMessage : "context error" ,
4564 },
@@ -57,10 +76,10 @@ func TestCreateAppVersionCommand(t *testing.T) {
5776
5877 mockVersionService := mockversions .NewMockVersionService (ctrl )
5978 if tt .shouldError {
60- mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), tt .request , true ).
79+ mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), tt .request , true , tt . dryRun ).
6180 Return (errors .New (tt .errorMessage )).Times (1 )
6281 } else {
63- mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), tt .request , true ).
82+ mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), tt .request , true , tt . dryRun ).
6483 Return (nil ).Times (1 )
6584 }
6685
@@ -69,6 +88,7 @@ func TestCreateAppVersionCommand(t *testing.T) {
6988 serverDetails : & config.ServerDetails {Url : "https://example.com" },
7089 requestPayload : tt .request ,
7190 sync : true ,
91+ dryRun : tt .dryRun ,
7292 }
7393
7494 err := cmd .Run ()
@@ -196,8 +216,8 @@ func TestCreateAppVersionCommand_FlagsSuite(t *testing.T) {
196216 var actualPayload * model.CreateAppVersionRequest
197217 mockVersionService := mockversions .NewMockVersionService (ctrl )
198218 if ! tt .expectsError {
199- mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), gomock .Any (), gomock .Any ()).
200- DoAndReturn (func (_ interface {}, req * model.CreateAppVersionRequest , _ bool ) error {
219+ mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), gomock .Any (), gomock .Any (), gomock . Any () ).
220+ DoAndReturn (func (_ interface {}, req * model.CreateAppVersionRequest , _ bool , _ bool ) error {
201221 actualPayload = req
202222 return nil
203223 }).Times (1 )
@@ -817,8 +837,8 @@ func TestCreateAppVersionCommand_SpecFileSuite(t *testing.T) {
817837 var capturedSync bool
818838 mockVersionService := mockversions .NewMockVersionService (ctrl )
819839 if ! tt .expectsError {
820- mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), gomock .Any (), gomock .Any ()).
821- DoAndReturn (func (_ interface {}, req * model.CreateAppVersionRequest , sync bool ) error {
840+ mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), gomock .Any (), gomock .Any (), gomock . Any () ).
841+ DoAndReturn (func (_ interface {}, req * model.CreateAppVersionRequest , sync , dryRun bool ) error {
822842 actualPayload = req
823843 capturedSync = sync
824844 return nil
@@ -886,8 +906,8 @@ func TestCreateAppVersionCommand_SyncFlagSuite(t *testing.T) {
886906
887907 var capturedSync bool
888908 mockVersionService := mockversions .NewMockVersionService (ctrl )
889- mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), gomock .Any (), gomock .Any ()).
890- DoAndReturn (func (_ interface {}, req * model.CreateAppVersionRequest , sync bool ) error {
909+ mockVersionService .EXPECT ().CreateAppVersion (gomock .Any (), gomock .Any (), gomock .Any (), gomock . Any () ).
910+ DoAndReturn (func (_ interface {}, req * model.CreateAppVersionRequest , sync , dryRun bool ) error {
891911 capturedSync = sync
892912 return nil
893913 }).Times (1 )
0 commit comments