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
When evaluating assertions for a test spec, `gdt` inspects the test's
546
+
`timeout`value to determine how long to retry the `get` call and recheck
547
+
the assertions.
548
+
549
+
If a test's `timeout` is empty, `gdt` inspects the scenario's
550
+
`defaults.timeout`value. If both of those values are empty, `gdt` will look
551
+
for any default `timeout` value that the plugin uses.
552
+
553
+
If you're interested in seeing the individual results of `gdt`'s
554
+
assertion-checks for a single `get` call, you can use the `gdt.WithDebug()`
555
+
function, like this test function demonstrates:
556
+
557
+
file: `testdata/matches.yaml`:
558
+
559
+
```yaml
560
+
name: matches
561
+
description: create a deployment and check the matches condition succeeds
562
+
fixtures:
563
+
- kind
564
+
tests:
565
+
- name: create-deployment
566
+
kube:
567
+
create: testdata/manifests/nginx-deployment.yaml
568
+
- name: deployment-exists
569
+
kube:
570
+
get: deployments/nginx
571
+
assert:
572
+
matches:
573
+
spec:
574
+
replicas: 2
575
+
template:
576
+
metadata:
577
+
labels:
578
+
app: nginx
579
+
status:
580
+
readyReplicas: 2
581
+
- name: delete-deployment
582
+
kube:
583
+
delete: deployments/nginx
584
+
```
585
+
586
+
file: `matches_test.go`
587
+
588
+
```go
589
+
import (
590
+
"github.com/gdt-dev/gdt"
591
+
_ "github.com/gdt-dev/kube"
592
+
kindfix "github.com/gdt-dev/kube/fixture/kind"
593
+
)
594
+
595
+
func TestMatches(t *testing.T) {
596
+
fp := filepath.Join("testdata", "matches.yaml")
597
+
598
+
kfix := kindfix.New()
599
+
600
+
s, err := gdt.From(fp)
601
+
602
+
ctx := gdt.NewContext(gdt.WithDebug())
603
+
ctx = gdt.RegisterFixture(ctx, "kind", kfix)
604
+
s.Run(ctx, t)
605
+
}
606
+
```
607
+
608
+
Here's what running `go test -v matches_test.go` would look like:
609
+
610
+
```
611
+
$ go test -v matches_test.go
612
+
=== RUN TestMatches
613
+
=== RUN TestMatches/matches
614
+
=== RUN TestMatches/matches/create-deployment
615
+
=== RUN TestMatches/matches/deployment-exists
616
+
deployment-exists (try 1 after 1.303µs) ok: false, terminal: false
617
+
deployment-exists (try 1 after 1.303µs) failure: assertion failed: match field not equal: $.status.readyReplicas not present in subject
618
+
deployment-exists (try 2 after 595.62786ms) ok: false, terminal: false
619
+
deployment-exists (try 2 after 595.62786ms) failure: assertion failed: match field not equal: $.status.readyReplicas not present in subject
620
+
deployment-exists (try 3 after 1.020003807s) ok: false, terminal: false
621
+
deployment-exists (try 3 after 1.020003807s) failure: assertion failed: match field not equal: $.status.readyReplicas not present in subject
622
+
deployment-exists (try 4 after 1.760006109s) ok: false, terminal: false
623
+
deployment-exists (try 4 after 1.760006109s) failure: assertion failed: match field not equal: $.status.readyReplicas had different values. expected 2 but found 1
624
+
deployment-exists (try 5 after 2.772416449s) ok: true, terminal: false
0 commit comments