Skip to content

Commit 6208eff

Browse files
committed
Testing spec ignore update scenarios
Signed-off-by: Tiago Angelo <[email protected]>
1 parent 9009c39 commit 6208eff

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

controllers/bucket_controller_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ func TestBucketReconciler_reconcileArtifact(t *testing.T) {
993993
},
994994
},
995995
{
996-
name: "Ignore checksum should be updated when spec ignore changes",
996+
name: "Ignore checksum must be removed when spec ignore is empty",
997997
beforeFunc: func(t *WithT, obj *sourcev1.Bucket, index *etagIndex, dir string) {
998998
obj.Spec.Interval = metav1.Duration{Duration: interval}
999999
obj.Status.IgnoreChecksum = "sha256:539530fbd29c252e357e36ddc065dc7923265e4ea795f09cada03287288f5e7a"
@@ -1006,6 +1006,21 @@ func TestBucketReconciler_reconcileArtifact(t *testing.T) {
10061006
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'"),
10071007
},
10081008
},
1009+
{
1010+
name: "Ignore checksum should be updated when spec ignore changes",
1011+
beforeFunc: func(t *WithT, obj *sourcev1.Bucket, index *etagIndex, dir string) {
1012+
obj.Spec.Interval = metav1.Duration{Duration: interval}
1013+
obj.Spec.Ignore = pointer.StringPtr("**.yaml\n")
1014+
obj.Status.IgnoreChecksum = "sha256:539530fbd29c252e357e36ddc065dc7923265e4ea795f09cada03287288f5e7a"
1015+
},
1016+
afterFunc: func(t *WithT, obj *sourcev1.Bucket, dir string) {
1017+
t.Expect(obj.Status.IgnoreChecksum).To(Equal("sha256:f4c4021b0b39597f03baee5f45fa6ef3d57c9fae57115ee3a54781b02e3a6cd8"))
1018+
},
1019+
want: sreconcile.ResultSuccess,
1020+
assertConditions: []metav1.Condition{
1021+
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'"),
1022+
},
1023+
},
10091024
}
10101025

10111026
for _, tt := range tests {

controllers/gitrepository_controller_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) {
854854
},
855855
},
856856
{
857-
name: "Ignore checksum should be updated when spec ignore changes",
857+
name: "Ignore checksum must be removed when spec ignore is empty",
858858
dir: "testdata/git/repository",
859859
beforeFunc: func(obj *sourcev1.GitRepository) {
860860
obj.Spec.Interval = metav1.Duration{Duration: interval}
@@ -868,6 +868,22 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) {
868868
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision 'main/revision'"),
869869
},
870870
},
871+
{
872+
name: "Ignore checksum should be updated when spec ignore changes",
873+
dir: "testdata/git/repository",
874+
beforeFunc: func(obj *sourcev1.GitRepository) {
875+
obj.Spec.Interval = metav1.Duration{Duration: interval}
876+
obj.Spec.Ignore = pointer.StringPtr("**.yaml\n")
877+
obj.Status.IgnoreChecksum = "sha256:539530fbd29c252e357e36ddc065dc7923265e4ea795f09cada03287288f5e7a"
878+
},
879+
afterFunc: func(t *WithT, obj *sourcev1.GitRepository) {
880+
t.Expect(obj.Status.IgnoreChecksum).To(Equal("sha256:f4c4021b0b39597f03baee5f45fa6ef3d57c9fae57115ee3a54781b02e3a6cd8"))
881+
},
882+
want: sreconcile.ResultSuccess,
883+
assertConditions: []metav1.Condition{
884+
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision 'main/revision'"),
885+
},
886+
},
871887
}
872888
artifactSize := func(g *WithT, artifactURL string) *int64 {
873889
if artifactURL == "" {

0 commit comments

Comments
 (0)