30
30
ws = "test-ws-id"
31
31
dagTarballVersionTest = "test-version"
32
32
dagsUploadTestURL = "test-url"
33
+ deploymentID = "test-id"
33
34
createDeployResponse = astrocore.CreateDeployResponse {
34
35
HTTPResponse : & http.Response {
35
36
StatusCode : 200 ,
74
75
IsDagDeployEnabled : false ,
75
76
},
76
77
}
78
+ mockCoreDeploymentResponse = []astrocore.Deployment {
79
+ {
80
+ Id : deploymentID ,
81
+ Status : "HEALTHY" ,
82
+ },
83
+ }
84
+ mockListDeploymentsResponse = astrocore.ListDeploymentsResponse {
85
+ HTTPResponse : & http.Response {
86
+ StatusCode : 200 ,
87
+ },
88
+ JSON200 : & astrocore.DeploymentsPaginated {
89
+ Deployments : mockCoreDeploymentResponse ,
90
+ },
91
+ }
77
92
)
78
93
79
94
func TestDeployWithoutDagsDeploySuccess (t * testing.T ) {
@@ -95,6 +110,7 @@ func TestDeployWithoutDagsDeploySuccess(t *testing.T) {
95
110
mockClient := new (astro_mocks.Client )
96
111
97
112
mockCoreClient .On ("GetDeploymentWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& deploymentResponse , nil ).Times (4 )
113
+ mockCoreClient .On ("ListDeploymentsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& mockListDeploymentsResponse , nil ).Times (1 )
98
114
mockClient .On ("ListDeployments" , org , ws ).Return ([]astro.Deployment {{ID : "test-id" , Workspace : astro.Workspace {ID : ws }}}, nil ).Once ()
99
115
mockCoreClient .On ("GetDeploymentOptionsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& getDeploymentOptionsResponse , nil ).Times (5 )
100
116
mockCoreClient .On ("CreateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& createDeployResponse , nil ).Times (5 )
@@ -201,7 +217,7 @@ func TestDeployOnCiCdEnforcedDeployment(t *testing.T) {
201
217
canCiCdDeploy = func (astroAPIToken string ) bool {
202
218
return false
203
219
}
204
-
220
+ mockCoreClient . On ( "ListDeploymentsWithResponse" , mock . Anything , mock . Anything , mock . Anything ). Return ( & mockListDeploymentsResponse , nil ). Times ( 1 )
205
221
mockClient .On ("ListDeployments" , org , ws ).Return ([]astro.Deployment {{ID : "test-id" , Workspace : astro.Workspace {ID : ws }, DagDeployEnabled : true , APIKeyOnlyDeployments : true }}, nil ).Once ()
206
222
207
223
err := Deploy (deployInput , mockClient , mockCoreClient )
@@ -237,6 +253,7 @@ func TestDeployWithDagsDeploySuccess(t *testing.T) {
237
253
238
254
mockCoreClient .On ("GetDeploymentWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& deploymentResponse , nil ).Times (5 )
239
255
mockClient .On ("ListDeployments" , org , ws ).Return ([]astro.Deployment {{ID : "test-id" , Workspace : astro.Workspace {ID : ws }, DagDeployEnabled : true }}, nil ).Times (2 )
256
+ mockCoreClient .On ("ListDeploymentsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& mockListDeploymentsResponse , nil ).Times (2 )
240
257
mockCoreClient .On ("GetDeploymentOptionsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& getDeploymentOptionsResponse , nil ).Times (7 )
241
258
mockCoreClient .On ("CreateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& createDeployResponse , nil ).Times (7 )
242
259
mockCoreClient .On ("UpdateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& updateDeployResponse , nil ).Times (7 )
@@ -393,6 +410,7 @@ func TestDagsDeploySuccess(t *testing.T) {
393
410
394
411
mockCoreClient .On ("GetDeploymentOptionsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& getDeploymentOptionsResponse , nil ).Times (3 )
395
412
mockClient .On ("ListDeployments" , mock .Anything , mock .Anything ).Return (mockDeplyResp , nil ).Times (5 )
413
+ mockCoreClient .On ("ListDeploymentsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& mockListDeploymentsResponse , nil ).Times (5 )
396
414
mockCoreClient .On ("CreateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& createDeployResponse , nil ).Times (5 )
397
415
mockCoreClient .On ("UpdateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& updateDeployResponse , nil ).Times (5 )
398
416
@@ -488,6 +506,7 @@ func TestNoDagsDeploy(t *testing.T) {
488
506
}
489
507
490
508
mockClient .On ("ListDeployments" , mock .Anything , mock .Anything ).Return (mockDeplyResp , nil ).Times (1 )
509
+ mockCoreClient .On ("ListDeploymentsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& mockListDeploymentsResponse , nil ).Times (1 )
491
510
mockCoreClient .On ("CreateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& createDeployResponse , nil ).Times (1 )
492
511
493
512
deployInput := InputDeploy {
@@ -553,6 +572,7 @@ func TestDagsDeployFailed(t *testing.T) {
553
572
Dags : true ,
554
573
}
555
574
mockClient .On ("ListDeployments" , mock .Anything , mock .Anything ).Return (mockDeplyResp , nil ).Times (3 )
575
+ mockCoreClient .On ("ListDeploymentsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& mockListDeploymentsResponse , nil ).Times (3 )
556
576
mockCoreClient .On ("GetDeploymentOptionsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& getDeploymentOptionsResponse , nil ).Times (2 )
557
577
mockCoreClient .On ("CreateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& createDeployResponse , nil ).Times (3 )
558
578
@@ -633,6 +653,7 @@ func TestDeployFailure(t *testing.T) {
633
653
testUtil .InitTestConfig (testUtil .CloudPlatform )
634
654
mockClient := new (astro_mocks.Client )
635
655
mockClient .On ("ListDeployments" , org , ws ).Return (mockDeplyResp , nil ).Times (2 )
656
+ mockCoreClient .On ("ListDeploymentsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& mockListDeploymentsResponse , nil ).Times (3 )
636
657
mockCoreClient .On ("CreateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& createDeployResponse , nil ).Times (2 )
637
658
mockCoreClient .On ("GetDeploymentOptionsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& getDeploymentOptionsResponse , nil ).Once ()
638
659
@@ -740,6 +761,7 @@ func TestDeployMonitoringDAGNonHosted(t *testing.T) {
740
761
741
762
mockCoreClient .On ("GetDeploymentOptionsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& getDeploymentOptionsResponse , nil ).Times (3 )
742
763
mockClient .On ("ListDeployments" , mock .Anything , mock .Anything ).Return (mockDeplyResp , nil ).Times (4 )
764
+ mockCoreClient .On ("ListDeploymentsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& mockListDeploymentsResponse , nil ).Times (4 )
743
765
mockCoreClient .On ("CreateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& createDeployResponse , nil ).Times (4 )
744
766
mockCoreClient .On ("UpdateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& updateDeployResponse , nil ).Times (4 )
745
767
@@ -844,6 +866,7 @@ func TestDeployNoMonitoringDAGHosted(t *testing.T) {
844
866
845
867
mockCoreClient .On ("GetDeploymentOptionsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& getDeploymentOptionsResponse , nil ).Times (3 )
846
868
mockClient .On ("ListDeployments" , mock .Anything , mock .Anything ).Return (mockDeplyResp , nil ).Times (4 )
869
+ mockCoreClient .On ("ListDeploymentsWithResponse" , mock .Anything , mock .Anything , mock .Anything ).Return (& mockListDeploymentsResponse , nil ).Times (4 )
847
870
mockCoreClient .On ("CreateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& createDeployResponse , nil ).Times (4 )
848
871
mockCoreClient .On ("UpdateDeployWithResponse" , mock .Anything , mock .Anything , mock .Anything , mock .Anything , mock .Anything ).Return (& updateDeployResponse , nil ).Times (4 )
849
872
0 commit comments