Skip to content

Commit

Permalink
add test for 'X' pattern to select latest patch (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
dguendisch authored Mar 8, 2022
1 parent 61de182 commit b426a28
Showing 1 changed file with 73 additions and 1 deletion.
74 changes: 73 additions & 1 deletion pkg/util/kubernetes_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,22 @@ var _ = Describe("kubernetes version util", func() {
))
})

It("should return latest patch of old minor version", func() {
It("should return latest patch of old minor version omitting patch and `filterPatchVersions: true`", func() {
pattern := "1.14"
filter := true
versionFlavor := common.ShootKubernetesVersionFlavor{
Pattern: &pattern,
FilterPatchVersions: &filter,
}

versions, err := util.GetK8sVersions(cloudprofile, versionFlavor, false)
Expect(err).ToNot(HaveOccurred())
Expect(versions).To(ConsistOf(
newExpirableVersion("1.14.6"),
))
})

It("should return latest patch of old minor version using '*' and `filterPatchVersions: true`", func() {
pattern := "1.14.*"
filter := true
versionFlavor := common.ShootKubernetesVersionFlavor{
Expand All @@ -83,6 +98,63 @@ var _ = Describe("kubernetes version util", func() {
))
})

It("should return latest patch of old minor version using 'X' and `filterPatchVersions: true`", func() {
pattern := "1.14.X"
filter := true
versionFlavor := common.ShootKubernetesVersionFlavor{
Pattern: &pattern,
FilterPatchVersions: &filter,
}

versions, err := util.GetK8sVersions(cloudprofile, versionFlavor, false)
Expect(err).ToNot(HaveOccurred())
Expect(versions).To(ConsistOf(
newExpirableVersion("1.14.6"),
))
})

It("should return all patch versions of an old minor version omitting patch and `filterPatchVersions`", func() {
pattern := "1.14"
versionFlavor := common.ShootKubernetesVersionFlavor{
Pattern: &pattern,
}

versions, err := util.GetK8sVersions(cloudprofile, versionFlavor, false)
Expect(err).ToNot(HaveOccurred())
Expect(versions).To(ConsistOf(
newExpirableVersion("1.14.5"),
newExpirableVersion("1.14.6"),
))
})

It("should return all patch versions of an old minor version using `*` and omitting `filterPatchVersions`", func() {
pattern := "1.14.*"
versionFlavor := common.ShootKubernetesVersionFlavor{
Pattern: &pattern,
}

versions, err := util.GetK8sVersions(cloudprofile, versionFlavor, false)
Expect(err).ToNot(HaveOccurred())
Expect(versions).To(ConsistOf(
newExpirableVersion("1.14.5"),
newExpirableVersion("1.14.6"),
))
})

It("should return all patch versions of an old minor version using `X` and omitting `filterPatchVersions`", func() {
pattern := "1.14.X"
versionFlavor := common.ShootKubernetesVersionFlavor{
Pattern: &pattern,
}

versions, err := util.GetK8sVersions(cloudprofile, versionFlavor, false)
Expect(err).ToNot(HaveOccurred())
Expect(versions).To(ConsistOf(
newExpirableVersion("1.14.5"),
newExpirableVersion("1.14.6"),
))
})

It("should return all versions", func() {
pattern := "*"
versionFlavor := common.ShootKubernetesVersionFlavor{
Expand Down

0 comments on commit b426a28

Please sign in to comment.