(t *testing.T)
| 102 | } |
| 103 | |
| 104 | func 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 | |
| 146 | type mockVerifier struct { |
| 147 | supported bool |
nothing calls this directly
no test coverage detected
searching dependent graphs…