Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 63 additions & 16 deletions eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ package kube_test
import (
"bufio"
"bytes"
"os"
"path/filepath"
"testing"

gdtcontext "github.com/gdt-dev/core/context"
"github.com/gdt-dev/gdt"
_ "github.com/gdt-dev/core/plugin/exec"
"github.com/gdt-dev/core/scenario"
"github.com/stretchr/testify/require"

kindfix "github.com/gdt-dev/kube/fixtures/kind"
Expand All @@ -27,8 +29,11 @@ func TestKindListPodsEmpty(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "list-pods-empty.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -44,8 +49,11 @@ func TestKindGetPodNotFound(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "get-pod-not-found.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -61,8 +69,11 @@ func TestKindCreateUnknownResource(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "create-unknown-resource.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -78,8 +89,11 @@ func TestKindSameNamedKind(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "same-named-kind.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -95,8 +109,11 @@ func TestKindDeleteResourceNotFound(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "delete-resource-not-found.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -112,8 +129,11 @@ func TestKindDeleteUnknownResource(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "delete-unknown-resource.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -129,8 +149,11 @@ func TestKindPodCreateGetDelete(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "create-get-delete-pod.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -146,8 +169,11 @@ func TestKindMatches(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "matches.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -163,8 +189,11 @@ func TestKindConditions(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "conditions.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -180,8 +209,11 @@ func TestKindJSON(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "json.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -197,8 +229,11 @@ func TestKindApply(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "apply-deployment.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -216,8 +251,11 @@ func TestKindEnvvarSubstitution(t *testing.T) {
t.Setenv("pod_name", "foo")

fp := filepath.Join("testdata", "kind", "envvar-substitution.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -233,8 +271,11 @@ func TestKindWithLabels(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "list-pods-with-labels.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -250,8 +291,11 @@ func TestKindVarSaveRestore(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "var-save-restore.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -269,8 +313,11 @@ func TestKindCurlPodIP(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "kind", "curl-pod-ip.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand Down
12 changes: 9 additions & 3 deletions fixtures/kind/kind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"testing"

gdtcontext "github.com/gdt-dev/core/context"
"github.com/gdt-dev/gdt"
"github.com/gdt-dev/core/scenario"
kindfix "github.com/gdt-dev/kube/fixtures/kind"
"github.com/stretchr/testify/require"
)
Expand All @@ -23,8 +23,11 @@ func TestDefaultSingleControlPlane(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "default-single-control-plane.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand All @@ -49,8 +52,11 @@ func TestOneControlPlaneOneWorker(t *testing.T) {
require := require.New(t)

fp := filepath.Join("testdata", "one-control-plane-one-worker.yaml")
f, err := os.Open(fp)
require.Nil(err)
defer f.Close() // nolint:errcheck

s, err := gdt.From(fp)
s, err := scenario.FromReader(f, scenario.WithPath(fp))
require.Nil(err)
require.NotNil(s)

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.24.3
require (
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/gdt-dev/core v1.10.0
github.com/gdt-dev/gdt v1.9.9
github.com/samber/lo v1.51.0
github.com/stretchr/testify v1.11.1
github.com/theory/jsonpath v0.10.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sa
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/gdt-dev/core v1.10.0 h1:yX0MG2Tt+O34JGDFWcS63LV47lWpizto4HAyR/ugAC0=
github.com/gdt-dev/core v1.10.0/go.mod h1:Bw8J6kUW0b7MUL8qW5e7qSbxb4SI9EAWQ0a4cAoPVpo=
github.com/gdt-dev/gdt v1.9.9 h1:GATWWI28mF6Vt7HAIOxMVYprgaIfH9tp2GyAkq/vZOg=
github.com/gdt-dev/gdt v1.9.9/go.mod h1:Zb8DKqBvjyEJXIySOlC6YLgdDlp2uNNtPjud8tDHmG4=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
Expand Down
Loading
Loading