Skip to content

Commit 7e218cb

Browse files
committed
Add test on getOpenStackReleaseVersion
1 parent 5656b32 commit 7e218cb

3 files changed

Lines changed: 45 additions & 4 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
260260
ENVTEST ?= $(LOCALBIN)/setup-envtest
261261
CRD_MARKDOWN ?= $(LOCALBIN)/crd-to-markdown
262262
GINKGO ?= $(LOCALBIN)/ginkgo
263-
GINKGO_TESTS ?= ./tests/... ./apis/client/...
263+
GINKGO_TESTS ?= ./tests/... ./apis/client/... ./apis/core/... ./apis/dataplane/...
264264

265265
KUTTL ?= $(LOCALBIN)/kubectl-kuttl
266266

‎apis/core/v1beta1/version_test.go‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package v1beta1
2+
3+
import (
4+
. "github.com/onsi/ginkgo/v2"
5+
. "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("OpenStackReleaseVersion", func() {
9+
10+
Context("test interal getOpenStackReleaseVersion", func() {
11+
12+
// NOTE: this is the default behavior where OPENSTACK_RELEASE_VERSION is just an environment variable
13+
// and enables the clearest understanding of the version number with regards to testing upgrades
14+
It("Generates a default version based on the OPENSTACK_RELEASE_VERSION when no mode is set", func() {
15+
Expect(
16+
getOpenStackReleaseVersion("1.2.3", "", "openstack-operator.v1.0.0-0.1724144685.p"),
17+
).To(Equal("1.2.3"))
18+
19+
})
20+
21+
It("Generates a default version based on the OPENSTACK_RELEASE_VERSION when invalid mode is set", func() {
22+
Expect(
23+
getOpenStackReleaseVersion("1.2.3", "asdf", "openstack-operator.v1.0.0-0.1724144685.p"),
24+
).To(Equal("1.2.3"))
25+
26+
})
27+
28+
// NOTE: this is what some downstream projects use for custom release automation
29+
// Will envolve extra understanding of the version number when testing upgrades with regards to how the
30+
// epoch gets appended
31+
It("Generates a version which appends the epoch when csvEpochAppend is enabled", func() {
32+
Expect(
33+
getOpenStackReleaseVersion("1.2.3", "csvEpochAppend", "openstack-operator.v1.0.0-0.1234567890.p"),
34+
).To(Equal("1.2.3.1234567890.p"))
35+
36+
})
37+
38+
})
39+
40+
})

‎apis/core/v1beta1/webhook_suite_test.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ package v1beta1
1818

1919
import (
2020
"testing"
21+
. "github.com/onsi/ginkgo/v2"
22+
. "github.com/onsi/gomega"
2123
)
2224

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

0 commit comments

Comments
 (0)