diff --git a/internal/eol_test.go b/internal/eol_test.go index 507103f..c4fb17f 100644 --- a/internal/eol_test.go +++ b/internal/eol_test.go @@ -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("")) }) + }) + }