mirror of https://github.com/fluxcd/flux2.git
add e2e test for check --pre with templating support
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>pull/1719/head
parent
a3ba9817a3
commit
cc32c1be07
@ -0,0 +1,40 @@
|
||||
// +build e2e
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/fluxcd/flux2/internal/utils"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
)
|
||||
|
||||
func TestCheckPre(t *testing.T) {
|
||||
jsonOutput, err := utils.ExecKubectlCommand(context.TODO(), utils.ModeCapture, rootArgs.kubeconfig, rootArgs.kubecontext, "version", "--output", "json")
|
||||
if err != nil {
|
||||
t.Fatalf("Error running utils.ExecKubectlCommand: %v", err.Error())
|
||||
}
|
||||
|
||||
var versions map[string]version.Info
|
||||
if err := json.Unmarshal([]byte(jsonOutput), &versions); err != nil {
|
||||
t.Fatalf("Error unmarshalling: %v", err.Error())
|
||||
}
|
||||
|
||||
clientVersion := strings.TrimPrefix(versions["clientVersion"].GitVersion, "v")
|
||||
serverVersion := strings.TrimPrefix(versions["serverVersion"].GitVersion, "v")
|
||||
|
||||
cmd := cmdTestCase{
|
||||
args: "check --pre",
|
||||
wantError: false,
|
||||
testClusterMode: ExistingClusterMode,
|
||||
templateValues: map[string]string{
|
||||
"clientVersion": clientVersion,
|
||||
"serverVersion": serverVersion,
|
||||
},
|
||||
goldenFile: "testdata/check/check_pre.golden",
|
||||
}
|
||||
cmd.runTestCmd(t)
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
► checking prerequisites
|
||||
✔ kubectl {{ .clientVersion }} >=1.18.0-0
|
||||
✔ Kubernetes {{ .serverVersion }} >=1.16.0-0
|
||||
✔ prerequisites checks passed
|
Loading…
Reference in New Issue