Skip to content

Commit

Permalink
Implement review comment v2
Browse files Browse the repository at this point in the history
  • Loading branch information
grischperl committed Jul 20, 2023
1 parent 74c0839 commit 086efd4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func Test_Validate_Defaulting(t *testing.T) {
},
},
wantMatches: gomega.And(
eventingMatchers.HaveBackendTypeNats(defaultBackend()),
eventingMatchers.HaveBackendTypeNats(defaultBackendConfig()),
eventingMatchers.HavePublisher(defaultPublisher()),
eventingMatchers.HavePublisherResources(defaultPublisherResources()),
eventingMatchers.HaveLogging(defaultLogging()),
Expand All @@ -516,7 +516,7 @@ func Test_Validate_Defaulting(t *testing.T) {
},
},
wantMatches: gomega.And(
eventingMatchers.HaveBackendTypeNats(defaultBackend()),
eventingMatchers.HaveBackendTypeNats(defaultBackendConfig()),
eventingMatchers.HavePublisher(defaultPublisher()),
eventingMatchers.HavePublisherResources(defaultPublisherResources()),
eventingMatchers.HaveLogging(defaultLogging()),
Expand Down Expand Up @@ -562,7 +562,7 @@ func Test_Validate_Defaulting(t *testing.T) {
},
},
wantMatches: gomega.And(
eventingMatchers.HaveBackendTypeNats(defaultBackend()),
eventingMatchers.HaveBackendTypeNats(defaultBackendConfig()),
),
},
{
Expand Down Expand Up @@ -670,15 +670,12 @@ func Test_Validate_Defaulting(t *testing.T) {
}
}

func defaultBackend() v1alpha1.Backend {
return v1alpha1.Backend{
Type: typeNats,
Config: v1alpha1.BackendConfig{
NATSStreamStorageType: storageTypeFile,
NATSStreamReplicas: 3,
NATSStreamMaxSize: resource.MustParse("700Mi"),
NATSMaxMsgsPerTopic: 1000000,
},
func defaultBackendConfig() v1alpha1.BackendConfig {
return v1alpha1.BackendConfig{
NATSStreamStorageType: storageTypeFile,
NATSStreamReplicas: 3,
NATSStreamMaxSize: resource.MustParse("700Mi"),
NATSMaxMsgsPerTopic: 1000000,
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/matchers/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
)

func HaveBackendTypeNats(b v1alpha1.Backend) gomegatypes.GomegaMatcher {
func HaveBackendTypeNats(bc v1alpha1.BackendConfig) gomegatypes.GomegaMatcher {
return gomega.And(
gomega.WithTransform(
func(e *v1alpha1.Eventing) string {
return e.Spec.Backends.Type
}, gomega.Equal(b.Type)),
}, gomega.Equal("NATS")),
gomega.WithTransform(
func(e *v1alpha1.Eventing) string {
return e.Spec.Backends.Config.NATSStreamStorageType
}, gomega.Equal(b.Config.NATSStreamStorageType)),
}, gomega.Equal(bc.NATSStreamStorageType)),
gomega.WithTransform(
func(e *v1alpha1.Eventing) int {
return e.Spec.Backends.Config.NATSStreamReplicas
}, gomega.Equal(b.Config.NATSStreamReplicas)),
}, gomega.Equal(bc.NATSStreamReplicas)),
gomega.WithTransform(
func(e *v1alpha1.Eventing) resource.Quantity {
return e.Spec.Backends.Config.NATSStreamMaxSize
}, gomega.Equal(b.Config.NATSStreamMaxSize)),
}, gomega.Equal(bc.NATSStreamMaxSize)),
gomega.WithTransform(
func(e *v1alpha1.Eventing) int {
return e.Spec.Backends.Config.NATSMaxMsgsPerTopic
}, gomega.Equal(b.Config.NATSMaxMsgsPerTopic)),
}, gomega.Equal(bc.NATSMaxMsgsPerTopic)),
)
}

Expand Down

0 comments on commit 086efd4

Please sign in to comment.