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
|
name string
|
||||||
beforeFunc func(obj *bucketv1.Bucket)
|
beforeFunc func(obj *bucketv1.Bucket)
|
||||||
assertConditions []metav1.Condition
|
assertConditions []metav1.Condition
|
||||||
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "positive conditions only",
|
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.StorageOperationFailedCondition, sourcev1.DirCreationFailedReason, "failed to create directory"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
||||||
},
|
},
|
||||||
|
wantErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mixed positive and negative conditions",
|
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.FetchFailedCondition, sourcev1.AuthenticationFailedReason, "failed to get secret"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
*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()
|
ctx := context.TODO()
|
||||||
recResult := sreconcile.ResultSuccess
|
|
||||||
var retErr error
|
|
||||||
|
|
||||||
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
||||||
summarizeOpts := []summarize.Option{
|
summarizeOpts := []summarize.Option{
|
||||||
summarize.WithConditions(bucketReadyCondition),
|
summarize.WithConditions(bucketReadyCondition),
|
||||||
summarize.WithReconcileResult(recResult),
|
summarize.WithReconcileResult(sreconcile.ResultSuccess),
|
||||||
summarize.WithReconcileError(retErr),
|
|
||||||
summarize.WithIgnoreNotFound(),
|
summarize.WithIgnoreNotFound(),
|
||||||
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
||||||
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
||||||
}),
|
}),
|
||||||
summarize.WithPatchFieldOwner("source-controller"),
|
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)
|
key := client.ObjectKeyFromObject(obj)
|
||||||
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
||||||
|
|
|
@ -2328,6 +2328,7 @@ func TestGitRepositoryReconciler_statusConditions(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
beforeFunc func(obj *sourcev1.GitRepository)
|
beforeFunc func(obj *sourcev1.GitRepository)
|
||||||
assertConditions []metav1.Condition
|
assertConditions []metav1.Condition
|
||||||
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "multiple positive conditions",
|
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.StorageOperationFailedCondition, sourcev1.DirCreationFailedReason, "failed to create directory"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
||||||
},
|
},
|
||||||
|
wantErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mixed positive and negative conditions",
|
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.FetchFailedCondition, sourcev1.AuthenticationFailedReason, "failed to get secret"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
*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()
|
ctx := context.TODO()
|
||||||
recResult := sreconcile.ResultSuccess
|
|
||||||
var retErr error
|
|
||||||
|
|
||||||
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
||||||
summarizeOpts := []summarize.Option{
|
summarizeOpts := []summarize.Option{
|
||||||
summarize.WithConditions(gitRepositoryReadyCondition),
|
summarize.WithConditions(gitRepositoryReadyCondition),
|
||||||
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
|
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
|
||||||
summarize.WithReconcileResult(recResult),
|
summarize.WithReconcileResult(sreconcile.ResultSuccess),
|
||||||
summarize.WithReconcileError(retErr),
|
|
||||||
summarize.WithIgnoreNotFound(),
|
summarize.WithIgnoreNotFound(),
|
||||||
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
||||||
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
||||||
}),
|
}),
|
||||||
summarize.WithPatchFieldOwner("source-controller"),
|
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)
|
key := client.ObjectKeyFromObject(obj)
|
||||||
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
||||||
|
|
|
@ -2029,6 +2029,7 @@ func TestHelmChartReconciler_statusConditions(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
beforeFunc func(obj *helmv1.HelmChart)
|
beforeFunc func(obj *helmv1.HelmChart)
|
||||||
assertConditions []metav1.Condition
|
assertConditions []metav1.Condition
|
||||||
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "positive conditions only",
|
name: "positive conditions only",
|
||||||
|
@ -2055,6 +2056,7 @@ func TestHelmChartReconciler_statusConditions(t *testing.T) {
|
||||||
*conditions.TrueCondition(sourcev1.BuildFailedCondition, "ChartPackageError", "some error"),
|
*conditions.TrueCondition(sourcev1.BuildFailedCondition, "ChartPackageError", "some error"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
||||||
},
|
},
|
||||||
|
wantErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mixed positive and negative conditions",
|
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.FetchFailedCondition, sourcev1.AuthenticationFailedReason, "failed to get secret"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
*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()
|
ctx := context.TODO()
|
||||||
recResult := sreconcile.ResultSuccess
|
|
||||||
var retErr error
|
|
||||||
|
|
||||||
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
||||||
summarizeOpts := []summarize.Option{
|
summarizeOpts := []summarize.Option{
|
||||||
summarize.WithConditions(helmChartReadyCondition),
|
summarize.WithConditions(helmChartReadyCondition),
|
||||||
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
|
summarize.WithBiPolarityConditionTypes(sourcev1.SourceVerifiedCondition),
|
||||||
summarize.WithReconcileResult(recResult),
|
summarize.WithReconcileResult(sreconcile.ResultSuccess),
|
||||||
summarize.WithReconcileError(retErr),
|
|
||||||
summarize.WithIgnoreNotFound(),
|
summarize.WithIgnoreNotFound(),
|
||||||
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{
|
||||||
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
RequeueAfter: jitter.JitteredIntervalDuration(obj.GetRequeueAfter()),
|
||||||
}),
|
}),
|
||||||
summarize.WithPatchFieldOwner("source-controller"),
|
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)
|
key := client.ObjectKeyFromObject(obj)
|
||||||
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
||||||
|
|
|
@ -1254,6 +1254,7 @@ func TestHelmRepositoryReconciler_statusConditions(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
beforeFunc func(obj *helmv1.HelmRepository)
|
beforeFunc func(obj *helmv1.HelmRepository)
|
||||||
assertConditions []metav1.Condition
|
assertConditions []metav1.Condition
|
||||||
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "positive conditions only",
|
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(meta.ReadyCondition, meta.SucceededReason, "stored artifact for revision"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
||||||
},
|
},
|
||||||
|
wantErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "multiple failures",
|
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.StorageOperationFailedCondition, sourcev1.DirCreationFailedReason, "failed to create directory"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
*conditions.TrueCondition(sourcev1.ArtifactOutdatedCondition, "NewRevision", "some error"),
|
||||||
},
|
},
|
||||||
|
wantErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mixed positive and negative conditions",
|
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.FetchFailedCondition, sourcev1.AuthenticationFailedReason, "failed to get secret"),
|
||||||
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision"),
|
*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()
|
ctx := context.TODO()
|
||||||
recResult := sreconcile.ResultSuccess
|
|
||||||
var retErr error
|
|
||||||
|
|
||||||
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
summarizeHelper := summarize.NewHelper(record.NewFakeRecorder(32), serialPatcher)
|
||||||
summarizeOpts := []summarize.Option{
|
summarizeOpts := []summarize.Option{
|
||||||
summarize.WithConditions(helmRepositoryReadyCondition),
|
summarize.WithConditions(helmRepositoryReadyCondition),
|
||||||
summarize.WithReconcileResult(recResult),
|
summarize.WithReconcileResult(sreconcile.ResultSuccess),
|
||||||
summarize.WithReconcileError(retErr),
|
|
||||||
summarize.WithIgnoreNotFound(),
|
summarize.WithIgnoreNotFound(),
|
||||||
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{RequeueAfter: obj.GetRequeueAfter()}),
|
summarize.WithResultBuilder(sreconcile.AlwaysRequeueResultBuilder{RequeueAfter: obj.GetRequeueAfter()}),
|
||||||
summarize.WithPatchFieldOwner("source-controller"),
|
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)
|
key := client.ObjectKeyFromObject(obj)
|
||||||
g.Expect(c.Get(ctx, key, obj)).ToNot(HaveOccurred())
|
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")
|
podinfoVersions, err := pushMultiplePodinfoImages(regServer.registryHost, true, "6.1.4", "6.1.5", "6.1.6")
|
||||||
|
g.Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
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")
|
podinfoVersions, err := pushMultiplePodinfoImages(regServer.registryHost, true, "6.1.4", "6.1.5", "6.1.6")
|
||||||
|
g.Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
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")
|
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"]
|
img6 := podinfoVersions["6.1.6"]
|
||||||
img5 := podinfoVersions["6.1.5"]
|
img5 := podinfoVersions["6.1.5"]
|
||||||
|
|
||||||
|
|
|
@ -364,16 +364,15 @@ func Test_sasTokenFromSecret(t *testing.T) {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
g := NewWithT(t)
|
g := NewWithT(t)
|
||||||
|
|
||||||
_, err := url.ParseQuery("")
|
|
||||||
got, err := sasTokenFromSecret(tt.endpoint, tt.secret)
|
got, err := sasTokenFromSecret(tt.endpoint, tt.secret)
|
||||||
g.Expect(err != nil).To(Equal(tt.wantErr))
|
g.Expect(err != nil).To(Equal(tt.wantErr))
|
||||||
if tt.want != "" {
|
if tt.want != "" {
|
||||||
ttVaules, err := url.Parse(tt.want)
|
ttValues, err := url.Parse(tt.want)
|
||||||
g.Expect(err).To(BeNil())
|
g.Expect(err).To(BeNil())
|
||||||
|
|
||||||
gotValues, err := url.Parse(got)
|
gotValues, err := url.Parse(got)
|
||||||
g.Expect(err).To(BeNil())
|
g.Expect(err).To(BeNil())
|
||||||
g.Expect(gotValues.Query()).To(Equal(ttVaules.Query()))
|
g.Expect(gotValues.Query()).To(Equal(ttValues.Query()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
g.Expect(got).To(Equal(""))
|
g.Expect(got).To(Equal(""))
|
||||||
|
|
Loading…
Reference in New Issue