You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`gdt-kube`test specs have some additional fields that allow you to take some
@@ -711,108 +720,6 @@ tests:
711
720
delete: deployments/nginx
712
721
```
713
722
714
-
### Timeouts and retrying `kube.get` assertions
715
-
716
-
When evaluating assertions for `kube.get`, `gdt` inspects the test's
717
-
`timeout.after`value to determine how long to retry the `get` call and recheck
718
-
the assertions.
719
-
720
-
If a test's `timeout.after` is empty, `gdt` inspects the scenario's
721
-
`defaults.timeout.after`value. If both of those values are empty, `gdt` will
722
-
use a **default timeout of 5 seconds**.
723
-
724
-
If you're interested in seeing the individual results of `gdt`'s
725
-
assertion-checks for a single `get` call, you can use the `gdt.WithDebug()`
726
-
function, like this test function demonstrates:
727
-
728
-
file: `testdata/matches.yaml`:
729
-
730
-
```yaml
731
-
name: matches
732
-
description: create a deployment and check the matches condition succeeds
733
-
fixtures:
734
-
- kind
735
-
tests:
736
-
- name: create-deployment
737
-
kube:
738
-
create: testdata/manifests/nginx-deployment.yaml
739
-
- name: deployment-exists
740
-
kube:
741
-
get: deployments/nginx
742
-
assert:
743
-
matches:
744
-
spec:
745
-
replicas: 2
746
-
template:
747
-
metadata:
748
-
labels:
749
-
app: nginx
750
-
status:
751
-
readyReplicas: 2
752
-
- name: delete-deployment
753
-
kube:
754
-
delete: deployments/nginx
755
-
```
756
-
757
-
file: `matches_test.go`
758
-
759
-
```go
760
-
import (
761
-
"github.com/gdt-dev/gdt"
762
-
_ "github.com/gdt-dev/kube"
763
-
kindfix "github.com/gdt-dev/kube/fixture/kind"
764
-
)
765
-
766
-
func TestMatches(t *testing.T) {
767
-
fp := filepath.Join("testdata", "matches.yaml")
768
-
769
-
kfix := kindfix.New()
770
-
771
-
s, err := gdt.From(fp)
772
-
773
-
ctx := gdt.NewContext(gdt.WithDebug())
774
-
ctx = gdt.RegisterFixture(ctx, "kind", kfix)
775
-
s.Run(ctx, t)
776
-
}
777
-
```
778
-
779
-
Here's what running `go test -v matches_test.go` would look like:
780
-
781
-
```
782
-
$ go test -v matches_test.go
783
-
=== RUN TestMatches
784
-
=== RUN TestMatches/matches
785
-
=== RUN TestMatches/matches/create-deployment
786
-
=== RUN TestMatches/matches/deployment-exists
787
-
deployment-exists (try 1 after 1.303µs) ok: false, terminal: false
788
-
deployment-exists (try 1 after 1.303µs) failure: assertion failed: match field not equal: $.status.readyReplicas not present in subject
789
-
deployment-exists (try 2 after 595.62786ms) ok: false, terminal: false
790
-
deployment-exists (try 2 after 595.62786ms) failure: assertion failed: match field not equal: $.status.readyReplicas not present in subject
791
-
deployment-exists (try 3 after 1.020003807s) ok: false, terminal: false
792
-
deployment-exists (try 3 after 1.020003807s) failure: assertion failed: match field not equal: $.status.readyReplicas not present in subject
793
-
deployment-exists (try 4 after 1.760006109s) ok: false, terminal: false
794
-
deployment-exists (try 4 after 1.760006109s) failure: assertion failed: match field not equal: $.status.readyReplicas had different values. expected 2 but found 1
795
-
deployment-exists (try 5 after 2.772416449s) ok: true, terminal: false
0 commit comments