mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-04-27 19:28:59 +00:00
Make test more robust
because on some workers machineID may come empty making the test fail Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
e3d7d3a057
commit
536c401f3c
@ -2,12 +2,13 @@ package action
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/Masterminds/sprig/v3"
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||
"github.com/kairos-io/kairos-sdk/state"
|
||||
"gopkg.in/yaml.v3"
|
||||
"os"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
func RenderTemplate(path string, config *config.Config, runtime state.Runtime) ([]byte, error) {
|
||||
|
@ -2,11 +2,12 @@ package action
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
agentConfig "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||
"github.com/kairos-io/kairos-sdk/collector"
|
||||
"github.com/kairos-io/kairos-sdk/state"
|
||||
"gopkg.in/yaml.v3"
|
||||
"os"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
@ -20,6 +21,7 @@ var _ = Describe("RenderTemplate action test", func() {
|
||||
"testKey": "testValue",
|
||||
}
|
||||
runtime, err := state.NewRuntime()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
fmt.Println(os.Getwd())
|
||||
|
||||
@ -30,9 +32,10 @@ var _ = Describe("RenderTemplate action test", func() {
|
||||
|
||||
var data map[string]string
|
||||
err = yaml.Unmarshal(result, &data)
|
||||
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(data).To(HaveKeyWithValue("configTest", "TESTVALUE"))
|
||||
Expect(data["stateTest"]).To(MatchRegexp("^[0-9a-f]{8}$"))
|
||||
Expect(data["stateTest"]).To(Equal("amd64"))
|
||||
})
|
||||
|
||||
})
|
||||
|
2
tests/fixtures/template/test.yaml
vendored
2
tests/fixtures/template/test.yaml
vendored
@ -1,2 +1,2 @@
|
||||
configTest: "{{.Config.testKey | upper}}"
|
||||
stateTest: "{{.State.uuid | trunc 8}}"
|
||||
stateTest: "{{.State.system.os.architecture}}"
|
||||
|
Loading…
Reference in New Issue
Block a user