Releases: gdt-dev/kube
v1.9.1
v1.9.0
v1.8.0
v1.4.0
What's Changed
- fix failure evaluation by @jaypipes in #8
- add ability to pass a KinD config to fixture by @jaypipes in #10
- add placement spread assertions by @jaypipes in #11
- back down to go1.21 by @jaypipes in #12
- allow KinD clusters to be deleted or retained by @jaypipes in #14
Full Changelog: v1.3.0...v1.4.0
v1.3.0
v1.1.1
Brings in [email protected] and ensures that the test units/specs call
testing.T.Error()
instead of relying on the Scenario.Run()
to do
that.
Also adds a custom YAML unmarshaler for the Expect
struct and adds
better parse-time errors for the matches
field as requested in Issue
8.
Addresses Issue gdt-dev/gdt#8
v1.1.0
New functionality
Skip scenario if condition true (gdt-dev/gdt#5)
Adds the ability to skip a test scenario if a condition evaluates to true. Use the skip-if
field in the Scenario
YAML to tell gdt
to skip the scenario if that condition evaluates to true. The condition is just a test.
For example, let's assume you have a gdt-kube
scenario that looks like
this:
tests:
- kube.create: manifests/nginx-deployment.yaml
- kube:
get: deployments/nginx
assert:
matches:
status:
readyReplicas: 2
- kube.delete: deployments/nginx
If you execute the above test and there is already an 'nginx'
deployment, the kube.create
test will fail. To prevent the scenario
from proceeding with the tests if an 'nginx' deployment already exists,
you could add the following
skip-if:
- kube.get: deployments/nginx
tests:
- kube.create: manifests/nginx-deployment.yaml
- kube:
get: deployments/nginx
assert:
matches:
status:
readyReplicas: 2
- kube.delete: deployments/nginx
With the above, if an 'nginx' deployment exists already, the scenario
will skip all the tests.
Breaking changes in YAML definitions
exec
plugin assertions now under assert
field (gdt-dev/gdt#6)
The exec
plugin now nests its assertions under an assert
field.
So, instead of this:
tests:
- exec: echo cat
out:
is: cat
you now do this:
tests:
- exec: echo cat
assert:
out:
is: cat
require
renamed to fixtures
(gdt-dev/gdt#2)
The require
field in the Scenario
YAML definition has been renamed to the more appropriate fixtures
, since this field lists the fixtures that the scenario requires.
kube
plugin assertions now in assert
field
The kube.assert
field in the kube
plugin's Spec
YAML definition has been renamed to the shorter assert
, matching both the exec
and http
plugin.
v1.0.0
Migration of github.com/jaypipes/gdt-kube
to github.com/gdt-dev/kube
.
To use gdt
, define your tests in a YAML file or a directory containing YAML files, use the gdt.From()
method to create a runnable test suite or scenario and then Run()
it:
package mypackage_test
import (
"context"
"path/filepath"
"testing"
"github.com/gdt-dev/gdt"
_ "github.com/gdt-dev/http"
"github.com/stretchr/testify/require"
)
func TestRunASuite(t *testing.T) {
require := assert.New(t)
fp := filepath.Join("suite", "testdata", "http")
s, err := gdt.From(fp)
require.Nil(err)
s.Run(context.TODO(), t)
}
func TestRunOneScenario(t *testing.T) {
require := require.New(t)
fp := filepath.Join("suite", "testdata", "http", "create-then-get-book.yaml")
s, err := gdt.From(fp)
require.Nil(err)
s.Run(context.TODO(), t)
}
Example gdt-kube
file: testdata/matches.yaml
:
name: matches
description: create a deployment and check the matches condition succeeds
require:
- kind
tests:
- name: create-deployment
kube:
create: testdata/manifests/nginx-deployment.yaml
- name: deployment-exists
kube:
get: deployments/nginx
assert:
matches:
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
status:
readyReplicas: 2
- name: delete-deployment
kube:
delete: deployments/nginx
file: matches_test.go
import (
"github.com/gdt-dev/gdt"
_ "github.com/gdt-dev/kube"
kindfix "github.com/gdt-dev/kube/fixture/kind"
)
func TestMatches(t *testing.T) {
fp := filepath.Join("testdata", "matches.yaml")
kfix := kindfix.New()
s, err := gdt.From(fp)
ctx := gdt.NewContext(gdt.WithDebug())
ctx = gdt.RegisterFixture(ctx, "kind", kfix)
s.Run(ctx, t)
}