Skip to content

Commit 55704fd

Browse files
committed
FIXUP: add assertion and link to IsDuration
1 parent 664070e commit 55704fd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/apis/postgres-operator.crunchydata.com/v1beta1/shared_types_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"time"
1111

1212
"gotest.tools/v3/assert"
13+
"k8s.io/kube-openapi/pkg/validation/strfmt"
1314
"sigs.k8s.io/yaml"
1415
)
1516

@@ -104,6 +105,10 @@ func TestDurationYAML(t *testing.T) {
104105
var parsed Duration
105106
assert.NilError(t, yaml.Unmarshal([]byte(tt.input), &parsed))
106107
assert.Equal(t, parsed.AsDuration().Duration, tt.result)
108+
109+
// This is what Kubernetes calls when validating the "duration" format.
110+
// - https://releases.k8s.io/v1.32.0/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go#L116
111+
assert.Assert(t, strfmt.IsDuration(tt.input))
107112
}
108113

109114
for _, tt := range []string{
@@ -122,6 +127,10 @@ func TestDurationYAML(t *testing.T) {
122127
} {
123128
assert.ErrorContains(t,
124129
yaml.Unmarshal([]byte(tt), new(Duration)), "unable to parse")
130+
131+
// This is what Kubernetes calls when validating the "duration" format.
132+
// - https://releases.k8s.io/v1.32.0/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go#L116
133+
assert.Assert(t, !strfmt.IsDuration(tt))
125134
}
126135
})
127136
}

0 commit comments

Comments
 (0)