misc: ensure return errs are captured
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
This commit is contained in:
parent
0288645875
commit
691d925add
|
@ -1293,6 +1293,7 @@ func TestBucketReconciler_statusConditions(t *testing.T) {
|
|||
name string
|
||||
beforeFunc func(obj *bucketv1.Bucket)
|
||||
assertConditions []metav1.Condition
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "positive conditions only",
|
||||
|
@ -1317,6 +1318,7 @@ func TestBucketReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(sourcev1.StorageOperationFailedCondition, sourcev1.DirCreationFailedReason, "failed to create directory"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "mixed positive and negative conditions",
|
||||
|
@ -1329,6 +1331,7 @@ func TestBucketReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(sourcev1.FetchFailedCondition, sourcev1.AuthenticationFailedReason, "failed to get secret"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1360,21 +1363,18 @@ func TestBucketReconciler_statusConditions(t *testing.T) {
|
|||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
recResult := sreconcile.ResultSuccess
|
||||
var retErr error
|
||||
|
||||
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
||||
summarizeOpts := []summarize.Option{
|
||||
summarize.WithConditions(bucketReadyCondition),
|
||||
summarize.WithReconcileResult(recResult),
|
||||
summarize.WithReconcileError(retErr),
|
||||
summarize.WithReconcileResult(sreconcile.ResultSuccess),
|
||||
summarize.WithIgnoreNotFound(),
|
||||
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
||||
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
||||
}),
|
||||
summarize.WithPatchFieldOwner("source-controller"),
|
||||
}
|
||||
_, retErr = summarizeHelper.SummarizeAndPatch(ctx, obj, summarizeOpts...)
|
||||
_, err := summarizeHelper.SummarizeAndPatch(ctx, obj, summarizeOpts...)
|
||||
g.Expect(err != nil).To(Equal(tt.wantErr))
|
||||
|
||||
key := client.ObjectKeyFromObject(obj)
|
||||
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
||||
|
|
|
@ -2328,6 +2328,7 @@ func TestGitRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
name string
|
||||
beforeFunc func(obj *sourcev1.GitRepository)
|
||||
assertConditions []metav1.Condition
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "multiple positive conditions",
|
||||
|
@ -2356,6 +2357,7 @@ func TestGitRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(sourcev1.StorageOperationFailedCondition, sourcev1.DirCreationFailedReason, "failed to create directory"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "mixed positive and negative conditions",
|
||||
|
@ -2368,6 +2370,7 @@ func TestGitRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(sourcev1.FetchFailedCondition, sourcev1.AuthenticationFailedReason, "failed to get secret"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -2400,22 +2403,19 @@ func TestGitRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
recResult := sreconcile.ResultSuccess
|
||||
var retErr error
|
||||
|
||||
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
||||
summarizeOpts := []summarize.Option{
|
||||
summarize.WithConditions(gitRepositoryReadyCondition),
|
||||
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
|
||||
summarize.WithReconcileResult(recResult),
|
||||
summarize.WithReconcileError(retErr),
|
||||
summarize.WithReconcileResult(sreconcile.ResultSuccess),
|
||||
summarize.WithIgnoreNotFound(),
|
||||
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
||||
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
||||
}),
|
||||
summarize.WithPatchFieldOwner("source-controller"),
|
||||
}
|
||||
_, retErr = summarizeHelper.SummarizeAndPatch(ctx, obj, summarizeOpts...)
|
||||
_, err := summarizeHelper.SummarizeAndPatch(ctx, obj, summarizeOpts...)
|
||||
g.Expect(err != nil).To(Equal(tt.wantErr))
|
||||
|
||||
key := client.ObjectKeyFromObject(obj)
|
||||
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
||||
|
|
|
@ -2029,6 +2029,7 @@ func TestHelmChartReconciler_statusConditions(t *testing.T) {
|
|||
name string
|
||||
beforeFunc func(obj *helmv1.HelmChart)
|
||||
assertConditions []metav1.Condition
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "positive conditions only",
|
||||
|
@ -2055,6 +2056,7 @@ func TestHelmChartReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(sourcev1.BuildFailedCondition, "ChartPackageError", "some error"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "mixed positive and negative conditions",
|
||||
|
@ -2067,6 +2069,7 @@ func TestHelmChartReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(sourcev1.FetchFailedCondition, sourcev1.AuthenticationFailedReason, "failed to get secret"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -2098,22 +2101,19 @@ func TestHelmChartReconciler_statusConditions(t *testing.T) {
|
|||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
recResult := sreconcile.ResultSuccess
|
||||
var retErr error
|
||||
|
||||
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
||||
summarizeOpts := []summarize.Option{
|
||||
summarize.WithConditions(helmChartReadyCondition),
|
||||
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
|
||||
summarize.WithReconcileResult(recResult),
|
||||
summarize.WithReconcileError(retErr),
|
||||
summarize.WithReconcileResult(sreconcile.ResultSuccess),
|
||||
summarize.WithIgnoreNotFound(),
|
||||
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
||||
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
||||
}),
|
||||
summarize.WithPatchFieldOwner("source-controller"),
|
||||
}
|
||||
_, retErr = summarizeHelper.SummarizeAndPatch(ctx, obj, summarizeOpts...)
|
||||
_, err := summarizeHelper.SummarizeAndPatch(ctx, obj, summarizeOpts...)
|
||||
g.Expect(err != nil).To(Equal(tt.wantErr))
|
||||
|
||||
key := client.ObjectKeyFromObject(obj)
|
||||
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
||||
|
|
|
@ -1254,6 +1254,7 @@ func TestHelmRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
name string
|
||||
beforeFunc func(obj *helmv1.HelmRepository)
|
||||
assertConditions []metav1.Condition
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "positive conditions only",
|
||||
|
@ -1264,6 +1265,7 @@ func TestHelmRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(meta.ReadyCondition, meta.SucceededReason, "stored artifact for revision"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "multiple failures",
|
||||
|
@ -1278,6 +1280,7 @@ func TestHelmRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(sourcev1.StorageOperationFailedCondition, sourcev1.DirCreationFailedReason, "failed to create directory"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "mixed positive and negative conditions",
|
||||
|
@ -1290,6 +1293,7 @@ func TestHelmRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
*conditions.TrueCondition(sourcev1.FetchFailedCondition, sourcev1.AuthenticationFailedReason, "failed to get secret"),
|
||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1321,19 +1325,16 @@ func TestHelmRepositoryReconciler_statusConditions(t *testing.T) {
|
|||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
recResult := sreconcile.ResultSuccess
|
||||
var retErr error
|
||||
|
||||
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
||||
summarizeOpts := []summarize.Option{
|
||||
summarize.WithConditions(helmRepositoryReadyCondition),
|
||||
summarize.WithReconcileResult(recResult),
|
||||
summarize.WithReconcileError(retErr),
|
||||
summarize.WithReconcileResult(sreconcile.ResultSuccess),
|
||||
summarize.WithIgnoreNotFound(),
|
||||
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{RequeueAfter: obj.GetRequeueAfter()}),
|
||||
summarize.WithPatchFieldOwner("source-controller"),
|
||||
}
|
||||
_, retErr = summarizeHelper.SummarizeAndPatch(ctx, obj, summarizeOpts...)
|
||||
_, err := summarizeHelper.SummarizeAndPatch(ctx, obj, summarizeOpts...)
|
||||
g.Expect(err != nil).To(Equal(tt.wantErr))
|
||||
|
||||
key := client.ObjectKeyFromObject(obj)
|
||||
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
||||
|
|
|
@ -119,6 +119,7 @@ func TestOCIRepository_Reconcile(t *testing.T) {
|
|||
})
|
||||
|
||||
podinfoVersions, err := pushMultiplePodinfoImages(regServer.registryHost, true, "6.1.4", "6.1.5", "6.1.6")
|
||||
g.Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
@ -305,6 +306,7 @@ func TestOCIRepository_Reconcile_MediaType(t *testing.T) {
|
|||
})
|
||||
|
||||
podinfoVersions, err := pushMultiplePodinfoImages(regServer.registryHost, true, "6.1.4", "6.1.5", "6.1.6")
|
||||
g.Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
@ -997,6 +999,8 @@ func TestOCIRepository_reconcileSource_remoteReference(t *testing.T) {
|
|||
})
|
||||
|
||||
podinfoVersions, err := pushMultiplePodinfoImages(server.registryHost, true, "6.1.4", "6.1.5", "6.1.6")
|
||||
g.Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
img6 := podinfoVersions["6.1.6"]
|
||||
img5 := podinfoVersions["6.1.5"]
|
||||
|
||||
|
|
|
@ -364,16 +364,15 @@ func Test_sasTokenFromSecret(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
g := NewWithT(t)
|
||||
|
||||
_, err := url.ParseQuery("")
|
||||
got, err := sasTokenFromSecret(tt.endpoint, tt.secret)
|
||||
g.Expect(err != nil).To(Equal(tt.wantErr))
|
||||
if tt.want != "" {
|
||||
ttVaules, err := url.Parse(tt.want)
|
||||
ttValues, err := url.Parse(tt.want)
|
||||
g.Expect(err).To(BeNil())
|
||||
|
||||
gotValues, err := url.Parse(got)
|
||||
g.Expect(err).To(BeNil())
|
||||
g.Expect(gotValues.Query()).To(Equal(ttVaules.Query()))
|
||||
g.Expect(gotValues.Query()).To(Equal(ttValues.Query()))
|
||||
return
|
||||
}
|
||||
g.Expect(got).To(Equal(""))
|
||||
|
|
Loading…
Reference in New Issue