mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-25 09:01:48 +00:00
fix e2e check test
The output of `kubectl version` has changed with newer kubectl version
from
```
{
"serverVersion": ...,
"clientVersion": ...
}
```
to
```
{
"serverVersion": ...,
"clientVersion": ...,
"kustomizeVersion": ...
}
```
So the `kustomizeVersion` field is new which causes the JSON
unmarshaling to fail.
We now just unmarshal it to `map[string]interface{}` and peel the
server git version out of that map manually w/o unmarshalling the JSON
into a custom type.
Signed-off-by: Max Jonas Werner <mail@makk.es>
This commit is contained in:
parent
e1def4f8ac
commit
9af6175302
1 changed files with 3 additions and 5 deletions
|
|
@ -22,11 +22,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/fluxcd/flux2/internal/utils"
|
"github.com/fluxcd/flux2/internal/utils"
|
||||||
"k8s.io/apimachinery/pkg/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCheckPre(t *testing.T) {
|
func TestCheckPre(t *testing.T) {
|
||||||
|
|
@ -35,17 +33,17 @@ func TestCheckPre(t *testing.T) {
|
||||||
t.Fatalf("Error running utils.ExecKubectlCommand: %v", err.Error())
|
t.Fatalf("Error running utils.ExecKubectlCommand: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
var versions map[string]version.Info
|
var versions map[string]interface{}
|
||||||
if err := json.Unmarshal([]byte(jsonOutput), &versions); err != nil {
|
if err := json.Unmarshal([]byte(jsonOutput), &versions); err != nil {
|
||||||
t.Fatalf("Error unmarshalling '%s': %v", jsonOutput, err.Error())
|
t.Fatalf("Error unmarshalling '%s': %v", jsonOutput, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
serverVersion := strings.TrimPrefix(versions["serverVersion"].GitVersion, "v")
|
serverGitVersion := versions["serverVersion"].(map[string]interface{})["gitVersion"].(string)
|
||||||
|
|
||||||
cmd := cmdTestCase{
|
cmd := cmdTestCase{
|
||||||
args: "check --pre",
|
args: "check --pre",
|
||||||
assert: assertGoldenTemplateFile("testdata/check/check_pre.golden", map[string]string{
|
assert: assertGoldenTemplateFile("testdata/check/check_pre.golden", map[string]string{
|
||||||
"serverVersion": serverVersion,
|
"serverVersion": serverGitVersion,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
cmd.runTestCmd(t)
|
cmd.runTestCmd(t)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue