this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pkg/encoding: add test cases for disjunction errors with Validate

For #4002.

Signed-off-by: Tavo Annus <tavo.annus@gmail.com>
Change-Id: I510b85de615386baaeccadeddf8208bc21e099d0
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1219284
Reviewed-by: Paul Jolly <paul@myitcv.io>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

authored by

Tavo Annus and committed by
Daniel Martí
51899326 741955cc

+18 -2
+13 -2
pkg/encoding/json/testdata/gen.txtar
··· 14 14 validate: disjunctionRequired: schema: {a!: int} | {b!: int} 15 15 validate: disjunctionClosed: schema: close({a: int}) | close({b: int}) 16 16 17 + validate: invalidDisjuntion: schema: {a: 1 | 2} 18 + 17 19 // Issue #2395 18 20 validate: enforceRequired: { 19 21 str: "{}" ··· 96 98 } 97 99 -- out/json -- 98 100 Errors: 101 + validate.invalidDisjuntion.result: error in call to encoding/json.Validate: 2 errors in empty disjunction:: 102 + ./in.cue:6:10 99 103 validate.t2.result: error in call to encoding/json.Validate: invalid value 10 (out of bound <3): 100 104 ./in.cue:6:10 101 105 ./in.cue:9:27 102 106 json.Validate:1:6 103 107 unmarshal.trailingInvalid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON: 104 - ./in.cue:47:11 108 + ./in.cue:49:11 105 109 unmarshal.trailingValid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON: 106 - ./in.cue:47:11 110 + ./in.cue:49:11 107 111 108 112 Result: 109 113 import "encoding/json" ··· 140 144 b: int 141 145 } 142 146 result: true 147 + } 148 + invalidDisjuntion: { 149 + str: *"{\"a\":10}" | string 150 + schema: { 151 + a: 1 | 2 152 + } 153 + result: _|_ // validate.invalidDisjuntion.result: error in call to encoding/json.Validate: validate.invalidDisjuntion.result.a: 2 errors in empty disjunction: (and 2 more errors) 143 154 } 144 155 145 156 // Issue #2395
+5
pkg/encoding/yaml/testdata/validate.txtar
··· 30 30 validatePartial: #test & { 31 31 fn: yaml.ValidatePartial 32 32 } 33 + 34 + invalidDisjuntion: yaml.Validate("a: 3", {a: 1 | 2}) 33 35 -- diff/todo -- 34 36 missing position 35 37 -- out/yaml -- ··· 48 50 ./in.cue:17:11 49 51 #test.t2.ok2: cannot call non-function fn (type _): 50 52 ./in.cue:18:11 53 + invalidDisjuntion: error in call to encoding/yaml.Validate: 2 errors in empty disjunction:: 54 + ./in.cue:33:20 51 55 52 56 Result: 53 57 import "encoding/yaml" ··· 115 119 ok2: "'foo'" 116 120 } 117 121 } 122 + invalidDisjuntion: _|_ // invalidDisjuntion: error in call to encoding/yaml.Validate: invalidDisjuntion.a: 2 errors in empty disjunction: