Skip to content

Commit

Permalink
Add test to check that provider returns a sorted list of versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitris Karakasilis committed Nov 4, 2022
1 parent 32dab70 commit 6bfd43d
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/provider_upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// nolint
package mos_test

import (
"encoding/json"

"github.com/kairos-io/kairos/tests/machine"
"github.com/mudler/go-pluggable"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"golang.org/x/mod/semver"
)

var _ = Describe("provider upgrade test", Label("provider-upgrade"), func() {
BeforeEach(func() {
machine.EventuallyConnects()
})

AfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
gatherLogs()
}
})

Context("agent.available_releases event", func() {
It("returns the available versions ordered", func() {
resultStr, _ := machine.SSHCommand(`echo '{ "config": ""}' | /system/providers/agent-provider-kairos agent.available_releases`)

var result pluggable.EventResponse

err := json.Unmarshal([]byte(resultStr), &result)
Expect(err).ToNot(HaveOccurred())

Expect(result.Data).ToNot(BeEmpty())
var versions []string
json.Unmarshal([]byte(result.Data), &versions)

Expect(versions).ToNot(BeEmpty())
sorted := make([]string, len(versions))
copy(sorted, versions)

semver.Sort(sorted)

Expect(sorted).To(Equal(versions))
})
})
})

0 comments on commit 6bfd43d

Please sign in to comment.