Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Commit

Permalink
fix tests and add labels.go for reconciler/pubsub/resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Lopez committed Feb 10, 2020
1 parent 9f3aeb5 commit a702bf9
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 79 deletions.
6 changes: 4 additions & 2 deletions pkg/reconciler/events/auditlogs/auditlogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func TestAllCases(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": sourceName,
}),
WithTopicOwnerReferences([]metav1.OwnerReference{sourceOwnerRef(sourceName, sourceUID)}),
),
Expand Down Expand Up @@ -371,7 +372,8 @@ func TestAllCases(t *testing.T) {
}),
WithPullSubscriptionSink(sinkGVK, sinkName),
WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": sourceName,
}),
WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand Down
5 changes: 1 addition & 4 deletions pkg/reconciler/events/pubsub/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ func (r *Reconciler) reconcilePullSubscription(ctx context.Context, source *v1al
Topic: source.Spec.Topic,
ResourceGroup: resourceGroup,
Mode: pubsubv1alpha1.ModePushCompatible,
Labels: map[string]string{
"receive-adapter": r.receiveAdapterName,
"source": source.Name,
},
Labels: resources.GetLabels(r.receiveAdapterName, source.Name),
}
newPS := resources.MakePullSubscription(args)
logging.FromContext(ctx).Desugar().Debug("Creating PullSubscription", zap.Any("ps", newPS))
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/events/pubsub/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func TestAllCases(t *testing.T) {
WithPullSubscriptionSink(sinkGVK, sinkName),
WithPullSubscriptionMode(pubsubv1alpha1.ModePushCompatible),
WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": pubsubName,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": pubsubName,
}),
WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand Down
7 changes: 4 additions & 3 deletions pkg/reconciler/events/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ func TestAllCases(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": schedulerName,
}),
WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
),
Expand Down Expand Up @@ -434,8 +435,8 @@ func TestAllCases(t *testing.T) {
}),
WithPullSubscriptionSink(sinkGVK, sinkName),
WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
}),
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": schedulerName}),
WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
}),
Expand Down
10 changes: 2 additions & 8 deletions pkg/reconciler/pubsub/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ func (psb *PubSubBase) ReconcilePubSub(ctx context.Context, pubsubable duck.PubS
Spec: spec,
Owner: pubsubable,
Topic: topic,
Labels: map[string]string{
"receive-adapter": psb.receiveAdapterName,
"source": name,
},
Labels: resources.GetLabels(psb.receiveAdapterName, name),
}
newTopic := resources.MakeTopic(args)
t, err = topics.Create(newTopic)
Expand Down Expand Up @@ -110,10 +107,7 @@ func (psb *PubSubBase) ReconcilePubSub(ctx context.Context, pubsubable duck.PubS
Topic: topic,
AdapterType: psb.adapterType,
ResourceGroup: resourceGroup,
Labels: map[string]string{
"receive-adapter": psb.receiveAdapterName,
"source": name,
},
Labels: resources.GetLabels(psb.receiveAdapterName, name),
}
newPS := resources.MakePullSubscription(args)
ps, err = pullSubscriptions.Create(newPS)
Expand Down
112 changes: 56 additions & 56 deletions pkg/reconciler/pubsub/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
),
Expand All @@ -109,8 +109,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
),
Expand All @@ -124,8 +124,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
),
Expand All @@ -137,8 +137,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
),
Expand All @@ -153,8 +153,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicReady(testTopicID),
Expand All @@ -168,8 +168,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicReady(testTopicID),
Expand All @@ -187,8 +187,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicProjectID(testProjectID),
Expand All @@ -202,8 +202,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicFailed(),
Expand All @@ -221,8 +221,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicProjectID(testProjectID),
Expand All @@ -236,8 +236,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicUnknown(),
Expand All @@ -255,8 +255,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicProjectID(testProjectID),
Expand All @@ -271,8 +271,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicReady(""),
Expand All @@ -291,8 +291,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicProjectID(testProjectID),
Expand All @@ -307,8 +307,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicReady(testTopicID),
Expand All @@ -322,8 +322,8 @@ func TestCreates(t *testing.T) {
Secret: &secret,
}),
rectesting.WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand All @@ -338,8 +338,8 @@ func TestCreates(t *testing.T) {
Secret: &secret,
}),
rectesting.WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand All @@ -356,8 +356,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicProjectID(testProjectID),
Expand All @@ -370,8 +370,8 @@ func TestCreates(t *testing.T) {
Secret: &secret,
}),
rectesting.WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand All @@ -386,8 +386,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicReady(testTopicID),
Expand All @@ -401,8 +401,8 @@ func TestCreates(t *testing.T) {
Secret: &secret,
}),
rectesting.WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand All @@ -419,8 +419,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicProjectID(testProjectID),
Expand All @@ -433,8 +433,8 @@ func TestCreates(t *testing.T) {
Secret: &secret,
}),
rectesting.WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand All @@ -450,8 +450,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicReady(testTopicID),
Expand All @@ -465,8 +465,8 @@ func TestCreates(t *testing.T) {
Secret: &secret,
}),
rectesting.WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand All @@ -484,8 +484,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicProjectID(testProjectID),
Expand All @@ -498,8 +498,8 @@ func TestCreates(t *testing.T) {
Secret: &secret,
}),
rectesting.WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand All @@ -515,8 +515,8 @@ func TestCreates(t *testing.T) {
PropagationPolicy: "CreateDelete",
}),
rectesting.WithTopicLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithTopicOwnerReferences([]metav1.OwnerReference{ownerRef()}),
rectesting.WithTopicReady(testTopicID),
Expand All @@ -530,8 +530,8 @@ func TestCreates(t *testing.T) {
Secret: &secret,
}),
rectesting.WithPullSubscriptionLabels(map[string]string{
"receive-adapter": receiveAdapterName,
"source": name,
"receive-adapter": receiveAdapterName,
"events.cloud.google.com/source-name": name,
}),
rectesting.WithPullSubscriptionAnnotations(map[string]string{
"metrics-resource-group": resourceGroup,
Expand Down
Loading

0 comments on commit a702bf9

Please sign in to comment.