|
|
@ -5,6 +5,7 @@ package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func TestTraceNoArgs(t *testing.T) {
|
|
|
|
func TestTraceNoArgs(t *testing.T) {
|
|
|
@ -15,36 +16,54 @@ func TestTraceNoArgs(t *testing.T) {
|
|
|
|
cmd.runTestCmd(t)
|
|
|
|
cmd.runTestCmd(t)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func toLocalTime(t *testing.T, in string) string {
|
|
|
|
|
|
|
|
ts, err := time.Parse(time.RFC3339, in)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatalf("Error converting golden test time '%s': %v", in, err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ts.Local().String()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestTrace(t *testing.T) {
|
|
|
|
func TestTrace(t *testing.T) {
|
|
|
|
cases := []struct {
|
|
|
|
cases := []struct {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
args string
|
|
|
|
args string
|
|
|
|
objectFile string
|
|
|
|
objectFile string
|
|
|
|
goldenFile string
|
|
|
|
goldenFile string
|
|
|
|
|
|
|
|
tmpl map[string]string
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"Deployment",
|
|
|
|
"Deployment",
|
|
|
|
"trace podinfo --kind deployment --api-version=apps/v1",
|
|
|
|
"trace podinfo --kind deployment --api-version=apps/v1",
|
|
|
|
"testdata/trace/deployment.yaml",
|
|
|
|
"testdata/trace/deployment.yaml",
|
|
|
|
"testdata/trace/deployment.golden",
|
|
|
|
"testdata/trace/deployment.golden",
|
|
|
|
|
|
|
|
map[string]string{
|
|
|
|
|
|
|
|
"ns": allocateNamespace("podinfo"),
|
|
|
|
|
|
|
|
"fluxns": allocateNamespace("flux-system"),
|
|
|
|
|
|
|
|
"helmReleaseLastReconcile": toLocalTime(t, "2021-07-16T15:42:20Z"),
|
|
|
|
|
|
|
|
"helmChartLastReconcile": toLocalTime(t, "2021-07-16T15:32:09Z"),
|
|
|
|
|
|
|
|
"helmRepositoryLastReconcile": toLocalTime(t, "2021-07-11T00:25:46Z"),
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"HelmRelease",
|
|
|
|
"HelmRelease",
|
|
|
|
"trace podinfo --kind HelmRelease --api-version=helm.toolkit.fluxcd.io/v2beta1",
|
|
|
|
"trace podinfo --kind HelmRelease --api-version=helm.toolkit.fluxcd.io/v2beta1",
|
|
|
|
"testdata/trace/helmrelease.yaml",
|
|
|
|
"testdata/trace/helmrelease.yaml",
|
|
|
|
"testdata/trace/helmrelease.golden",
|
|
|
|
"testdata/trace/helmrelease.golden",
|
|
|
|
|
|
|
|
map[string]string{
|
|
|
|
|
|
|
|
"ns": allocateNamespace("podinfo"),
|
|
|
|
|
|
|
|
"fluxns": allocateNamespace("flux-system"),
|
|
|
|
|
|
|
|
"kustomizationLastReconcile": toLocalTime(t, "2021-08-01T04:52:56Z"),
|
|
|
|
|
|
|
|
"gitRepositoryLastReconcile": toLocalTime(t, "2021-07-20T00:48:16Z"),
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
|
|
for _, tc := range cases {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
tmpl := map[string]string{
|
|
|
|
testEnv.CreateObjectFile(tc.objectFile, tc.tmpl, t)
|
|
|
|
"ns": allocateNamespace("podinfo"),
|
|
|
|
|
|
|
|
"fluxns": allocateNamespace("flux-system"),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
testEnv.CreateObjectFile(tc.objectFile, tmpl, t)
|
|
|
|
|
|
|
|
cmd := cmdTestCase{
|
|
|
|
cmd := cmdTestCase{
|
|
|
|
args: tc.args + " -n=" + tmpl["ns"],
|
|
|
|
args: tc.args + " -n=" + tc.tmpl["ns"],
|
|
|
|
assert: assertGoldenTemplateFile(tc.goldenFile, tmpl),
|
|
|
|
assert: assertGoldenTemplateFile(tc.goldenFile, tc.tmpl),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmd.runTestCmd(t)
|
|
|
|
cmd.runTestCmd(t)
|
|
|
|
})
|
|
|
|
})
|
|
|
|