Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding Horizon Spec #159

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions tests/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
)

func DefaultHorizonTemplate(name types.NamespacedName) *horizon.Horizon {
return &horizon.Horizon{
func CreateHorizon(name types.NamespacedName, spec horizon.HorizonSpec) *horizon.Horizon {
instance := &horizon.Horizon{
TypeMeta: metav1.TypeMeta{
APIVersion: "horizon.openstack.org/v1alpha1",
Kind: "Horizon",
Expand All @@ -40,22 +40,22 @@ func DefaultHorizonTemplate(name types.NamespacedName) *horizon.Horizon {
Name: name.Name,
Namespace: name.Namespace,
},
Spec: horizon.HorizonSpec{
ContainerImage: "test-horizon-container-image",
Secret: SecretName,
MemcachedInstance: "memcached",
},
Spec: spec,
}
}

func CreateHorizon(name types.NamespacedName) *horizon.Horizon {
instance := DefaultHorizonTemplate(name)
err := k8sClient.Create(ctx, instance)
Expect(err).NotTo(HaveOccurred())

return instance
}

func GetDefaultHorizonSpec() horizon.HorizonSpec {
return horizon.HorizonSpec{
ContainerImage: "test-horizon-container-image",
Secret: SecretName,
MemcachedInstance: "memcached",
}
}

func GetHorizon(name types.NamespacedName) *horizon.Horizon {
instance := &horizon.Horizon{}
gomega.Eventually(func(g gomega.Gomega) error {
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/horizon_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var _ = Describe("Horizon controller", func() {

When("A Horizon instance is created", func() {
BeforeEach(func() {
DeferCleanup(DeleteInstance, CreateHorizon(horizonName))
DeferCleanup(DeleteInstance, CreateHorizon(horizonName, GetDefaultHorizonSpec()))
})

It("should have the Spec and Status fields initialized", func() {
Expand Down Expand Up @@ -65,7 +65,7 @@ var _ = Describe("Horizon controller", func() {

When("an unrelated secret is provided", func() {
BeforeEach(func() {
DeferCleanup(DeleteInstance, CreateHorizon(horizonName))
DeferCleanup(DeleteInstance, CreateHorizon(horizonName, GetDefaultHorizonSpec()))
})
It("should remain in a state of waiting for the proper secret", func() {
secret = &corev1.Secret{
Expand All @@ -87,7 +87,7 @@ var _ = Describe("Horizon controller", func() {

When("the proper secret is provided", func() {
BeforeEach(func() {
DeferCleanup(DeleteInstance, CreateHorizon(horizonName))
DeferCleanup(DeleteInstance, CreateHorizon(horizonName, GetDefaultHorizonSpec()))
})
It("should be in a state of having the input ready", func() {
secret = &corev1.Secret{
Expand All @@ -108,7 +108,7 @@ var _ = Describe("Horizon controller", func() {

When("using a shared memcached instance", func() {
BeforeEach(func() {
DeferCleanup(DeleteInstance, CreateHorizon(horizonName))
DeferCleanup(DeleteInstance, CreateHorizon(horizonName, GetDefaultHorizonSpec()))
DeferCleanup(DeleteInstance, CreateHorizonMemcached())
secret = &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Loading