mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-06-03 01:44:53 +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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"os"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
"github.com/Masterminds/sprig/v3"
|
"github.com/Masterminds/sprig/v3"
|
||||||
"github.com/kairos-io/kairos-agent/v2/pkg/config"
|
"github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||||
"github.com/kairos-io/kairos-sdk/state"
|
"github.com/kairos-io/kairos-sdk/state"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"os"
|
|
||||||
"text/template"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func RenderTemplate(path string, config *config.Config, runtime state.Runtime) ([]byte, error) {
|
func RenderTemplate(path string, config *config.Config, runtime state.Runtime) ([]byte, error) {
|
||||||
|
@ -2,11 +2,12 @@ package action
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
agentConfig "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
agentConfig "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||||
"github.com/kairos-io/kairos-sdk/collector"
|
"github.com/kairos-io/kairos-sdk/collector"
|
||||||
"github.com/kairos-io/kairos-sdk/state"
|
"github.com/kairos-io/kairos-sdk/state"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"os"
|
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -20,6 +21,7 @@ var _ = Describe("RenderTemplate action test", func() {
|
|||||||
"testKey": "testValue",
|
"testKey": "testValue",
|
||||||
}
|
}
|
||||||
runtime, err := state.NewRuntime()
|
runtime, err := state.NewRuntime()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
fmt.Println(os.Getwd())
|
fmt.Println(os.Getwd())
|
||||||
|
|
||||||
@ -30,9 +32,10 @@ var _ = Describe("RenderTemplate action test", func() {
|
|||||||
|
|
||||||
var data map[string]string
|
var data map[string]string
|
||||||
err = yaml.Unmarshal(result, &data)
|
err = yaml.Unmarshal(result, &data)
|
||||||
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(data).To(HaveKeyWithValue("configTest", "TESTVALUE"))
|
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}}"
|
configTest: "{{.Config.testKey | upper}}"
|
||||||
stateTest: "{{.State.uuid | trunc 8}}"
|
stateTest: "{{.State.system.os.architecture}}"
|
||||||
|
Loading…
Reference in New Issue
Block a user