MCPcopy
hub / github.com/kubernetes/kubectl / TestConjunctiveSchema

Function TestConjunctiveSchema

pkg/validation/schema_test.go:104–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestConjunctiveSchema(t *testing.T) {
105 tests := []struct {
106 schemas []Schema
107 shouldPass bool
108 name string
109 }{
110 {
111 schemas: []Schema{NullSchema{}, NullSchema{}},
112 shouldPass: true,
113 name: "all pass",
114 },
115 {
116 schemas: []Schema{NullSchema{}, AlwaysInvalidSchema{}},
117 shouldPass: false,
118 name: "one fail",
119 },
120 {
121 schemas: []Schema{AlwaysInvalidSchema{}, AlwaysInvalidSchema{}},
122 shouldPass: false,
123 name: "all fail",
124 },
125 {
126 schemas: []Schema{},
127 shouldPass: true,
128 name: "empty",
129 },
130 }
131
132 for _, tt := range tests {
133 t.Run(tt.name, func(t *testing.T) {
134 schema := ConjunctiveSchema(tt.schemas)
135 err := schema.ValidateBytes([]byte{})
136 if err != nil && tt.shouldPass {
137 t.Errorf("Unexpected error: %v in %s", err, tt.name)
138 }
139 if err == nil && !tt.shouldPass {
140 t.Errorf("Unexpected non-error: %s", tt.name)
141 }
142 })
143 }
144}
145
146type mockVerifier struct {
147 supported bool

Callers

nothing calls this directly

Calls 3

ConjunctiveSchemaTypeAlias · 0.85
ValidateBytesMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…