@@ -1409,7 +1409,7 @@ func TestImageUpdateAutomationReconciler_e2e(t *testing.T) {
1409
1409
}
1410
1410
}
1411
1411
1412
- func TestImageUpdateAutomationReconciler_defaulting (t * testing.T ) {
1412
+ func TestImageUpdateAutomationReconciler_DefaultUpdate (t * testing.T ) {
1413
1413
g := NewWithT (t )
1414
1414
1415
1415
branch := rand .String (8 )
@@ -1468,6 +1468,70 @@ func TestImageUpdateAutomationReconciler_defaulting(t *testing.T) {
1468
1468
To (Equal (& imagev1.UpdateStrategy {Strategy : imagev1 .UpdateStrategySetters }))
1469
1469
}
1470
1470
1471
+ func TestImageUpdateAutomationReconciler_DefaultStrategy (t * testing.T ) {
1472
+ g := NewWithT (t )
1473
+
1474
+ branch := rand .String (8 )
1475
+ ctx , cancel := context .WithTimeout (context .Background (), timeout )
1476
+ defer cancel ()
1477
+
1478
+ // Create a test namespace.
1479
+ namespace , err := testEnv .CreateNamespace (ctx , "image-auto-test" )
1480
+ g .Expect (err ).ToNot (HaveOccurred ())
1481
+ defer func () { g .Expect (testEnv .Delete (ctx , namespace )).To (Succeed ()) }()
1482
+
1483
+ // Create an instance of ImageUpdateAutomation.
1484
+ key := types.NamespacedName {
1485
+ Name : "update-" + rand .String (5 ),
1486
+ Namespace : namespace .Name ,
1487
+ }
1488
+ auto := & imagev1.ImageUpdateAutomation {
1489
+ ObjectMeta : metav1.ObjectMeta {
1490
+ Name : key .Name ,
1491
+ Namespace : key .Namespace ,
1492
+ },
1493
+ Spec : imagev1.ImageUpdateAutomationSpec {
1494
+ SourceRef : imagev1.CrossNamespaceSourceReference {
1495
+ Kind : "GitRepository" ,
1496
+ Name : "garbage" ,
1497
+ },
1498
+ Interval : metav1.Duration {Duration : 2 * time .Hour },
1499
+ GitSpec : & imagev1.GitSpec {
1500
+ Checkout : & imagev1.GitCheckoutSpec {
1501
+ Reference : sourcev1.GitRepositoryRef {
1502
+ Branch : branch ,
1503
+ },
1504
+ },
1505
+ Commit : imagev1.CommitSpec {
1506
+ Author : imagev1.CommitUser {
1507
+ Email : testAuthorEmail ,
1508
+ },
1509
+ MessageTemplate : "nothing" ,
1510
+ },
1511
+ },
1512
+ Update : & imagev1.UpdateStrategy {
1513
+ Path : "./test-path" ,
1514
+ },
1515
+ },
1516
+ }
1517
+ g .Expect (testEnv .Create (ctx , auto )).To (Succeed ())
1518
+ defer func () {
1519
+ g .Expect (testEnv .Delete (ctx , auto )).To (Succeed ())
1520
+ }()
1521
+
1522
+ // Should default .spec.update to {strategy: Setters}.
1523
+ var fetchedAuto imagev1.ImageUpdateAutomation
1524
+ g .Eventually (func () bool {
1525
+ err := testEnv .Get (ctx , key , & fetchedAuto )
1526
+ return err == nil
1527
+ }, timeout , time .Second ).Should (BeTrue ())
1528
+ g .Expect (fetchedAuto .Spec .Update ).
1529
+ To (Equal (& imagev1.UpdateStrategy {
1530
+ Strategy : imagev1 .UpdateStrategySetters ,
1531
+ Path : "./test-path" ,
1532
+ }))
1533
+ }
1534
+
1471
1535
func TestImageUpdateAutomationReconciler_notify (t * testing.T ) {
1472
1536
g := NewWithT (t )
1473
1537
testPushResult , err := source .NewPushResult ("branch" , "rev" , "test commit message" )
0 commit comments