Skip to content

Commit

Permalink
Add test on getOpenStackReleaseVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
dprince committed Sep 18, 2024
1 parent 5656b32 commit 7e218cb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
CRD_MARKDOWN ?= $(LOCALBIN)/crd-to-markdown
GINKGO ?= $(LOCALBIN)/ginkgo
GINKGO_TESTS ?= ./tests/... ./apis/client/...
GINKGO_TESTS ?= ./tests/... ./apis/client/... ./apis/core/... ./apis/dataplane/...

KUTTL ?= $(LOCALBIN)/kubectl-kuttl

Expand Down
40 changes: 40 additions & 0 deletions apis/core/v1beta1/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v1beta1

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("OpenStackReleaseVersion", func() {

Context("test interal getOpenStackReleaseVersion", func() {

// NOTE: this is the default behavior where OPENSTACK_RELEASE_VERSION is just an environment variable
// and enables the clearest understanding of the version number with regards to testing upgrades
It("Generates a default version based on the OPENSTACK_RELEASE_VERSION when no mode is set", func() {
Expect(
getOpenStackReleaseVersion("1.2.3", "", "openstack-operator.v1.0.0-0.1724144685.p"),
).To(Equal("1.2.3"))

})

It("Generates a default version based on the OPENSTACK_RELEASE_VERSION when invalid mode is set", func() {
Expect(
getOpenStackReleaseVersion("1.2.3", "asdf", "openstack-operator.v1.0.0-0.1724144685.p"),
).To(Equal("1.2.3"))

})

// NOTE: this is what some downstream projects use for custom release automation
// Will envolve extra understanding of the version number when testing upgrades with regards to how the
// epoch gets appended
It("Generates a version which appends the epoch when csvEpochAppend is enabled", func() {
Expect(
getOpenStackReleaseVersion("1.2.3", "csvEpochAppend", "openstack-operator.v1.0.0-0.1234567890.p"),
).To(Equal("1.2.3.1234567890.p"))

})

})

})
7 changes: 4 additions & 3 deletions apis/core/v1beta1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package v1beta1

import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
// Implement later
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Controller v1beta1 Suite")
}

0 comments on commit 7e218cb

Please sign in to comment.