Skip to content

Commit 885c9f2

Browse files
authored
Merge pull request #980 from fluxcd/gitrepo-test-cleanup
GitRepo: git impl. deprecation test cleanup
2 parents e877040 + 8126c99 commit 885c9f2

File tree

1 file changed

+31
-42
lines changed

1 file changed

+31
-42
lines changed

controllers/gitrepository_controller_test.go

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -470,29 +470,23 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
470470
},
471471
}
472472

473-
t.Run(sourcev1.GoGitImplementation, func(t *testing.T) {
474-
g := NewWithT(t)
475-
476-
tmpDir := t.TempDir()
477-
478-
obj := obj.DeepCopy()
473+
tmpDir := t.TempDir()
479474

480-
head, _ := localRepo.Head()
481-
assertConditions := tt.assertConditions
482-
for k := range assertConditions {
483-
assertConditions[k].Message = strings.ReplaceAll(assertConditions[k].Message, "<commit>", head.Hash().String())
484-
assertConditions[k].Message = strings.ReplaceAll(assertConditions[k].Message, "<url>", obj.Spec.URL)
485-
}
475+
head, _ := localRepo.Head()
476+
assertConditions := tt.assertConditions
477+
for k := range assertConditions {
478+
assertConditions[k].Message = strings.ReplaceAll(assertConditions[k].Message, "<commit>", head.Hash().String())
479+
assertConditions[k].Message = strings.ReplaceAll(assertConditions[k].Message, "<url>", obj.Spec.URL)
480+
}
486481

487-
var commit git.Commit
488-
var includes artifactSet
482+
var commit git.Commit
483+
var includes artifactSet
489484

490-
got, err := r.reconcileSource(context.TODO(), obj, &commit, &includes, tmpDir)
491-
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(tt.assertConditions))
492-
g.Expect(err != nil).To(Equal(tt.wantErr))
493-
g.Expect(got).To(Equal(tt.want))
494-
g.Expect(commit).ToNot(BeNil())
495-
})
485+
got, err := r.reconcileSource(context.TODO(), obj, &commit, &includes, tmpDir)
486+
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(tt.assertConditions))
487+
g.Expect(err != nil).To(Equal(tt.wantErr))
488+
g.Expect(got).To(Equal(tt.want))
489+
g.Expect(commit).ToNot(BeNil())
496490
})
497491
}
498492
}
@@ -664,30 +658,25 @@ func TestGitRepositoryReconciler_reconcileSource_checkoutStrategy(t *testing.T)
664658
obj.Spec.Reference.Commit = headRef.Hash().String()
665659
}
666660

667-
t.Run(sourcev1.GoGitImplementation, func(t *testing.T) {
668-
g := NewWithT(t)
669-
670-
tmpDir := t.TempDir()
671-
obj := obj.DeepCopy()
661+
tmpDir := t.TempDir()
672662

673-
if tt.beforeFunc != nil {
674-
tt.beforeFunc(obj, headRef.Hash().String())
675-
}
663+
if tt.beforeFunc != nil {
664+
tt.beforeFunc(obj, headRef.Hash().String())
665+
}
676666

677-
var commit git.Commit
678-
var includes artifactSet
679-
got, err := r.reconcileSource(ctx, obj, &commit, &includes, tmpDir)
680-
if err != nil {
681-
println(err.Error())
682-
}
683-
g.Expect(err != nil).To(Equal(tt.wantErr))
684-
g.Expect(got).To(Equal(tt.want))
685-
if tt.wantRevision != "" && !tt.wantErr {
686-
revision := strings.ReplaceAll(tt.wantRevision, "<commit>", headRef.Hash().String())
687-
g.Expect(commit.String()).To(Equal(revision))
688-
g.Expect(conditions.IsTrue(obj, sourcev1.ArtifactOutdatedCondition)).To(Equal(tt.wantArtifactOutdated))
689-
}
690-
})
667+
var commit git.Commit
668+
var includes artifactSet
669+
got, err := r.reconcileSource(ctx, obj, &commit, &includes, tmpDir)
670+
if err != nil {
671+
println(err.Error())
672+
}
673+
g.Expect(err != nil).To(Equal(tt.wantErr))
674+
g.Expect(got).To(Equal(tt.want))
675+
if tt.wantRevision != "" && !tt.wantErr {
676+
revision := strings.ReplaceAll(tt.wantRevision, "<commit>", headRef.Hash().String())
677+
g.Expect(commit.String()).To(Equal(revision))
678+
g.Expect(conditions.IsTrue(obj, sourcev1.ArtifactOutdatedCondition)).To(Equal(tt.wantArtifactOutdated))
679+
}
691680
})
692681
}
693682
}

0 commit comments

Comments
 (0)