Skip to content

Commit 41e2a7a

Browse files
bryan-coxclaude
andcommitted
fix(ci): configure Codecov PR comments and add unit tests
- Set wait_for_ci: false so Codecov posts PR comments immediately instead of waiting for pending Prow e2e statuses that never resolve - Set comment behavior: new so each push gets a fresh comment - Add per-file coverage diffs to PR comment layout - Add unit tests for String, GetRevision, and GetKubeVersionForSupportedVersion Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c25481f commit 41e2a7a

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

codecov.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
codecov:
22
branch: main
3+
notify:
4+
wait_for_ci: false
35

46
comment:
5-
layout: "condensed_header, diff, flags, components"
7+
layout: "condensed_header, diff, files, flags, components"
8+
behavior: new

support/supportedversion/version_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,64 @@ func TestSupportedVersions(t *testing.T) {
2828
g.Expect(Supported()).To(Equal([]string{"4.22", "4.21", "4.20", "4.19", "4.18", "4.17", "4.16", "4.15", "4.14"}))
2929
}
3030

31+
func TestString(t *testing.T) {
32+
g := NewGomegaWithT(t)
33+
result := String()
34+
g.Expect(result).To(ContainSubstring("openshift/hypershift:"))
35+
g.Expect(result).To(ContainSubstring("Latest supported OCP:"))
36+
g.Expect(result).To(ContainSubstring(LatestSupportedVersion.String()))
37+
}
38+
39+
func TestGetRevision(t *testing.T) {
40+
g := NewGomegaWithT(t)
41+
revision := GetRevision()
42+
g.Expect(revision).ToNot(BeEmpty())
43+
}
44+
45+
func TestGetKubeVersionForSupportedVersion(t *testing.T) {
46+
testCases := []struct {
47+
name string
48+
ocpVersion string
49+
expectedKubeVer string
50+
expectErr bool
51+
}{
52+
{
53+
name: "When OCP 4.18 is provided it should return Kubernetes 1.31",
54+
ocpVersion: "4.18.0",
55+
expectedKubeVer: "1.31.0",
56+
},
57+
{
58+
name: "When OCP 4.14 is provided it should return Kubernetes 1.27",
59+
ocpVersion: "4.14.0",
60+
expectedKubeVer: "1.27.0",
61+
},
62+
{
63+
name: "When OCP 4.21 is provided it should return Kubernetes 1.34",
64+
ocpVersion: "4.21.0",
65+
expectedKubeVer: "1.34.0",
66+
},
67+
{
68+
name: "When an unmapped OCP version is provided it should return an error",
69+
ocpVersion: "4.99.0",
70+
expectErr: true,
71+
},
72+
}
73+
74+
for _, tc := range testCases {
75+
t.Run(tc.name, func(t *testing.T) {
76+
g := NewGomegaWithT(t)
77+
ver := semver.MustParse(tc.ocpVersion)
78+
kubeVer, err := GetKubeVersionForSupportedVersion(ver)
79+
if tc.expectErr {
80+
g.Expect(err).To(HaveOccurred())
81+
} else {
82+
g.Expect(err).ToNot(HaveOccurred())
83+
g.Expect(kubeVer.String()).To(Equal(tc.expectedKubeVer))
84+
}
85+
})
86+
}
87+
}
88+
3189
func TestIsValidReleaseVersion(t *testing.T) {
3290
v := func(str string) *semver.Version {
3391
result := semver.MustParse(str)

0 commit comments

Comments
 (0)