@@ -479,8 +479,10 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
479
479
// test cases and cleanup at the end.
480
480
481
481
t .Run ("PushSpec" , func (t * testing.T ) {
482
+ g := NewWithT (t )
483
+
482
484
// Clone the repo locally.
483
- cloneCtx , cancel := context .WithTimeout (ctx , time . Second * 10 )
485
+ cloneCtx , cancel := context .WithTimeout (ctx , timeout )
484
486
defer cancel ()
485
487
localRepo , err := clone (cloneCtx , cloneLocalRepoURL , branch )
486
488
g .Expect (err ).ToNot (HaveOccurred (), "failed to clone git repo" )
@@ -499,6 +501,8 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
499
501
pushBranch := "pr-" + randStringRunes (5 )
500
502
501
503
t .Run ("update with PushSpec" , func (t * testing.T ) {
504
+ g := NewWithT (t )
505
+
502
506
preChangeCommitId := commitIdFromBranch (localRepo , branch )
503
507
commitInRepo (g , cloneLocalRepoURL , branch , "Install setter marker" , func (tmp string ) {
504
508
g .Expect (replaceMarker (tmp , policyKey )).To (Succeed ())
@@ -536,6 +540,8 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
536
540
})
537
541
538
542
t .Run ("push branch gets updated" , func (t * testing.T ) {
543
+ g := NewWithT (t )
544
+
539
545
initialHead , err := headFromBranch (localRepo , branch )
540
546
g .Expect (err ).ToNot (HaveOccurred ())
541
547
defer initialHead .Free ()
@@ -566,6 +572,8 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
566
572
})
567
573
568
574
t .Run ("still pushes to the push branch after it's merged" , func (t * testing.T ) {
575
+ g := NewWithT (t )
576
+
569
577
initialHead , err := headFromBranch (localRepo , branch )
570
578
g .Expect (err ).ToNot (HaveOccurred ())
571
579
defer initialHead .Free ()
@@ -610,13 +618,15 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
610
618
})
611
619
612
620
t .Run ("with update strategy setters" , func (t * testing.T ) {
621
+ g := NewWithT (t )
622
+
613
623
// Clone the repo locally.
614
624
// NOTE: A new localRepo is created here instead of reusing the one
615
625
// in the previous case due to a bug in some of the git operations
616
626
// test helper. When switching branches, the localRepo seems to get
617
627
// stuck in one particular branch. As a workaround, create a
618
628
// separate localRepo.
619
- cloneCtx , cancel := context .WithTimeout (ctx , time . Second * 10 )
629
+ cloneCtx , cancel := context .WithTimeout (ctx , timeout )
620
630
defer cancel ()
621
631
localRepo , err := clone (cloneCtx , cloneLocalRepoURL , branch )
622
632
g .Expect (err ).ToNot (HaveOccurred (), "failed to clone git repo" )
@@ -677,6 +687,8 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
677
687
})
678
688
679
689
t .Run ("no reconciliation when object is suspended" , func (t * testing.T ) {
690
+ g := NewWithT (t )
691
+
680
692
err = createImagePolicyWithLatestImage (testEnv , imagePolicyName , namespace , "not-expected-to-exist" , "1.x" , latestImage )
681
693
g .Expect (err ).ToNot (HaveOccurred (), "failed to create ImagePolicy resource" )
682
694
@@ -863,7 +875,7 @@ func compareRepoWithExpected(g *WithT, repoURL, branch, fixture string, changeFi
863
875
864
876
copy .Copy (fixture , expected )
865
877
changeFixture (expected )
866
- cloneCtx , cancel := context .WithTimeout (ctx , time . Second * 10 )
878
+ cloneCtx , cancel := context .WithTimeout (ctx , timeout )
867
879
defer cancel ()
868
880
repo , err := clone (cloneCtx , repoURL , branch )
869
881
g .Expect (err ).ToNot (HaveOccurred ())
@@ -909,7 +921,7 @@ func configureTransportOptsForRepo(repo *libgit2.Repository) (func(), error) {
909
921
}
910
922
911
923
func commitInRepo (g * WithT , repoURL , branch , msg string , changeFiles func (path string )) * libgit2.Oid {
912
- cloneCtx , cancel := context .WithTimeout (ctx , time . Second * 10 )
924
+ cloneCtx , cancel := context .WithTimeout (ctx , timeout )
913
925
defer cancel ()
914
926
repo , err := clone (cloneCtx , repoURL , branch )
915
927
g .Expect (err ).ToNot (HaveOccurred ())
@@ -1443,7 +1455,7 @@ func testWithCustomRepoAndImagePolicy(
1443
1455
1444
1456
// Clone the repo.
1445
1457
repoURL := gitServer .HTTPAddressWithCredentials () + repositoryPath
1446
- cloneCtx , cancel := context .WithTimeout (ctx , time . Second * 10 )
1458
+ cloneCtx , cancel := context .WithTimeout (ctx , timeout )
1447
1459
defer cancel ()
1448
1460
localRepo , err := clone (cloneCtx , repoURL , args .branch )
1449
1461
g .Expect (err ).ToNot (HaveOccurred (), "failed to clone git repo" )
0 commit comments