kairos-agent/pkg/github/releases_test.go
Itxaka 1f316097be bug: Fix version list (#1323)
* 🐛 Fix version list

First version in the list is the latest one.
Alos moves the check for same version above the current place, so it can
check before asking if you want to update to the same version

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>

* 🌱 Rework versioning for upgrade

Use the semver lib to parse the versions into a proper collection where
it can be parsed and versions compared and sorted properly

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>

* 🤖 lint

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>

---------

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
2023-04-20 09:57:58 +02:00

28 lines
786 B
Go

package github_test
import (
"context"
"testing"
"github.com/kairos-io/kairos/v2/pkg/github"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestReleases(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Releases Suite")
}
var _ = Describe("Releases", func() {
It("can find the proper releases in order", func() {
releases, err := github.FindReleases(context.Background(), "", "kairos-io/kairos")
Expect(err).ToNot(HaveOccurred())
Expect(len(releases)).To(BeNumerically(">", 0))
// Expect the one at the bottom to be the first "real" release of kairos
Expect(releases[len(releases)-1].Original()).To(Equal("v1.0.0"))
// Expect the first one to be greater than the last one
Expect(releases[0].GreaterThan(releases[len(releases)-1]))
})
})