Skip to content

Commit

Permalink
Simplified test cases in eol_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
c0d1ngm0nk3y committed Jun 26, 2024
1 parent 47d06f6 commit f35f117
Showing 1 changed file with 14 additions and 64 deletions.
78 changes: 14 additions & 64 deletions internal/eol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,92 +45,42 @@ func testGetEolDate(t *testing.T, context spec.G, it spec.S) {
{
"cycle": "10.0",
"releaseDate": "2020-12-03",
"eol": "2022-10-31",
"eol": "2026-12-31",
"minJavaVersion": 8,
"latest": "10.0.27",
"latestReleaseDate": "2022-10-03",
"latestReleaseDate": "2025-10-03",
"lts": false
},
{
"cycle": "9",
"releaseDate": "2017-09-27",
"eol": false,
"eol": "2023-12-31",
"minJavaVersion": 8,
"latest": "9.0.89",
"latestReleaseDate": "2024-05-03",
"latestReleaseDate": "2021-05-03",
"lts": false
}
]`)))
})

it("returns correct cycle", func() {
eolDate, err := internal.GetEolDate("foo", "10.0.0")
it("finds release cycle by major and minor version", func() {
eolDate, err := internal.GetEolDate("foo", "10.0.1")
Expect(err).NotTo(HaveOccurred())
Expect(eolDate).To(Equal("2022-10-31T00:00:00Z"))
})
})

context("finds release cycle by major version", func() {
it.Before(func() {
httpmock.RegisterResponder(http.MethodGet, "https://endoflife.date/api/foo.json", httpmock.NewBytesResponder(200, []byte(`
[
{
"cycle": "10",
"releaseDate": "2022-09-23",
"eol": "2024-10-31",
"minJavaVersion": 11,
"latest": "10.1.24",
"latestReleaseDate": "2024-05-09",
"lts": false
},
{
"cycle": "9",
"releaseDate": "2020-12-03",
"eol": "2022-10-31",
"minJavaVersion": 8,
"latest": "9.0.27",
"latestReleaseDate": "2022-10-03",
"lts": false
}
]`)))
Expect(eolDate).To(Equal("2026-12-31T00:00:00Z"))
})

it("returns correct cycle", func() {
eolDate, err := internal.GetEolDate("foo", "10.1.1")
it("finds release cycle by major version", func() {
eolDate, err := internal.GetEolDate("foo", "9.5.4")
Expect(err).NotTo(HaveOccurred())
Expect(eolDate).To(Equal("2024-10-31T00:00:00Z"))
})
})

context("cycle.EOL is bool", func() {
it.Before(func() {
httpmock.RegisterResponder(http.MethodGet, "https://endoflife.date/api/foo.json", httpmock.NewBytesResponder(200, []byte(`
[
{
"cycle": "10",
"releaseDate": "2022-09-23",
"eol": false,
"minJavaVersion": 11,
"latest": "10.1.24",
"latestReleaseDate": "2024-05-09",
"lts": false
},
{
"cycle": "9",
"releaseDate": "2020-12-03",
"eol": "2022-10-31",
"minJavaVersion": 8,
"latest": "9.0.27",
"latestReleaseDate": "2022-10-03",
"lts": false
}
]`)))
Expect(eolDate).To(Equal("2023-12-31T00:00:00Z"))
})

it("returns empty eol date", func() {
eolDate, err := internal.GetEolDate("foo", "10.0.0")
it("returns empty eol date if eol is a bool", func() {
eolDate, err := internal.GetEolDate("foo", "10.1.0")
Expect(err).NotTo(HaveOccurred())
Expect(eolDate).To(Equal(""))
})

})

}

0 comments on commit f35f117

Please sign in to comment.