@@ -310,7 +310,7 @@ func TestGetAppDBImage(t *testing.T) {
310
310
want : "quay.io/mongodb/mongodb-enterprise-server:4.2.11-ubi8" ,
311
311
setupEnvs : func (t * testing.T ) {
312
312
t .Setenv (construct .MongodbRepoUrl , "quay.io/mongodb" )
313
- t .Setenv (construct .MongodbImageEnv , util .OfficialServerImageAppdbUrl )
313
+ t .Setenv (construct .MongodbImageEnv , util .OfficialEnterpriseServerImageUrl )
314
314
},
315
315
},
316
316
{
@@ -319,7 +319,7 @@ func TestGetAppDBImage(t *testing.T) {
319
319
want : "quay.io/mongodb/mongodb-enterprise-server:4.2.11-ubi8" ,
320
320
setupEnvs : func (t * testing.T ) {
321
321
t .Setenv (construct .MongodbRepoUrl , "quay.io/mongodb" )
322
- t .Setenv (construct .MongodbImageEnv , util .OfficialServerImageAppdbUrl )
322
+ t .Setenv (construct .MongodbImageEnv , util .OfficialEnterpriseServerImageUrl )
323
323
},
324
324
},
325
325
{
@@ -328,7 +328,7 @@ func TestGetAppDBImage(t *testing.T) {
328
328
want : "quay.io/mongodb/mongodb-enterprise-server:4.2.11-something" ,
329
329
setupEnvs : func (t * testing.T ) {
330
330
t .Setenv (construct .MongodbRepoUrl , "quay.io/mongodb" )
331
- t .Setenv (construct .MongodbImageEnv , util .OfficialServerImageAppdbUrl )
331
+ t .Setenv (construct .MongodbImageEnv , util .OfficialEnterpriseServerImageUrl )
332
332
},
333
333
},
334
334
{
@@ -337,7 +337,7 @@ func TestGetAppDBImage(t *testing.T) {
337
337
want : "quay.io/mongodb/mongodb-enterprise-server:4.2.11-ubi8" ,
338
338
setupEnvs : func (t * testing.T ) {
339
339
t .Setenv (construct .MongodbRepoUrl , "quay.io/mongodb" )
340
- t .Setenv (construct .MongodbImageEnv , util .OfficialServerImageAppdbUrl )
340
+ t .Setenv (construct .MongodbImageEnv , util .OfficialEnterpriseServerImageUrl )
341
341
},
342
342
},
343
343
{
@@ -368,7 +368,7 @@ func TestGetAppDBImage(t *testing.T) {
368
368
t .Setenv ("RELATED_IMAGE_MONGODB_IMAGE_4_2_11_ubi8" , "quay.io/mongodb/mongodb-enterprise-server:4.2.11-ubi8" )
369
369
t .Setenv ("RELATED_IMAGE_MONGODB_IMAGE_4_2_11_ent" , "quay.io/mongodb/mongodb-enterprise-server:4.2.11-ent" )
370
370
t .Setenv (construct .MongoDBImageType , "ubi8" )
371
- t .Setenv (construct .MongodbImageEnv , util .OfficialServerImageAppdbUrl )
371
+ t .Setenv (construct .MongodbImageEnv , util .OfficialEnterpriseServerImageUrl )
372
372
t .Setenv (construct .MongodbRepoUrl , construct .OfficialMongodbRepoUrls [1 ])
373
373
},
374
374
},
@@ -388,7 +388,7 @@ func TestGetAppDBImage(t *testing.T) {
388
388
want : "quay.io/mongodb/mongodb-enterprise-server:4.2.11-ent" ,
389
389
setupEnvs : func (t * testing.T ) {
390
390
t .Setenv (construct .MongodbRepoUrl , "quay.io/mongodb" )
391
- t .Setenv (construct .MongodbImageEnv , util .OfficialServerImageAppdbUrl )
391
+ t .Setenv (construct .MongodbImageEnv , util .OfficialEnterpriseServerImageUrl )
392
392
t .Setenv (util .MdbAppdbAssumeOldFormat , "true" )
393
393
},
394
394
},
@@ -401,7 +401,7 @@ func TestGetAppDBImage(t *testing.T) {
401
401
want : "quay.io/mongodb/mongodb-enterprise-server:4.2.11-ubi9" ,
402
402
setupEnvs : func (t * testing.T ) {
403
403
t .Setenv (construct .MongodbRepoUrl , "quay.io/mongodb" )
404
- t .Setenv (construct .MongodbImageEnv , util .OfficialServerImageAppdbUrl )
404
+ t .Setenv (construct .MongodbImageEnv , util .OfficialEnterpriseServerImageUrl )
405
405
},
406
406
},
407
407
{
@@ -413,7 +413,7 @@ func TestGetAppDBImage(t *testing.T) {
413
413
want : "quay.io/mongodb/mongodb-enterprise-server:4.2.11-ubi9" ,
414
414
setupEnvs : func (t * testing.T ) {
415
415
t .Setenv (construct .MongodbRepoUrl , "quay.io/mongodb" )
416
- t .Setenv (construct .MongodbImageEnv , util .OfficialServerImageAppdbUrl )
416
+ t .Setenv (construct .MongodbImageEnv , util .OfficialEnterpriseServerImageUrl )
417
417
},
418
418
},
419
419
}
@@ -538,3 +538,54 @@ func TestGetAutomationLogEnvVars(t *testing.T) {
538
538
assert .Contains (t , envVars , corev1.EnvVar {Name : LogFileAutomationAgentStderrEnv , Value : path .Join (util .PvcMountPathLogs , "automation-agent-stderr.log" )})
539
539
})
540
540
}
541
+
542
+ func TestDeploymentIsEnterpriseImage (t * testing.T ) {
543
+ tests := []struct {
544
+ name string
545
+ isStatic bool // this sets the environment to be static
546
+ envVarValue string // if static, we will set the respective environment variable to overwrite the used image
547
+ expectedResult bool
548
+ }{
549
+ {
550
+ name : "Static Architecture - Enterprise Image" ,
551
+ envVarValue : "myregistry.com/mongo/mongodb-enterprise-server:latest" ,
552
+ isStatic : true ,
553
+ expectedResult : true ,
554
+ },
555
+ {
556
+ name : "Non-Static Architecture - Enterprise Image" ,
557
+ envVarValue : "myregistry.com/mongo/mongodb-enterprise-server:latest" ,
558
+ isStatic : false ,
559
+ expectedResult : true ,
560
+ },
561
+ {
562
+ name : "Static Architecture - Community Image" ,
563
+ envVarValue : "myregistry.com/mongo/mongodb-community-server:latest" ,
564
+ isStatic : true ,
565
+ expectedResult : false ,
566
+ },
567
+ {
568
+ name : "Non-Static Architecture - Community Image" ,
569
+ envVarValue : "myregistry.com/mongo/mongodb-community-server:latest" ,
570
+ isStatic : false ,
571
+ expectedResult : false ,
572
+ },
573
+ }
574
+
575
+ for _ , tt := range tests {
576
+ t .Run (tt .name , func (t * testing.T ) {
577
+ if tt .isStatic {
578
+ t .Setenv (construct .MongodbImageEnv , tt .envVarValue )
579
+ t .Setenv (architectures .DefaultEnvArchitecture , string (architectures .Static ))
580
+ } else {
581
+ t .Setenv (util .NonStaticDatabaseEnterpriseImage , tt .envVarValue )
582
+ }
583
+
584
+ result := DeploymentIsEnterpriseImage (map [string ]string {})
585
+
586
+ if result != tt .expectedResult {
587
+ t .Errorf ("expected %v, got %v" , tt .expectedResult , result )
588
+ }
589
+ })
590
+ }
591
+ }
0 commit comments