@@ -56,7 +56,8 @@ fn reject_empty_namespace_priorities() {
5656 "default-priorities" : { "namespace" : [ ] } ,
5757 "variants" : { "fast" : { "cpu" : { "level" : [ "v2" , "v3" ] } } , "null" : { } }
5858 } ) ;
59- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
59+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
60+ . expect_err ( "namespace priorities must not be empty" ) ;
6061 assert_snapshot ! ( error, @"Variant namespace priorities must be non-empty and unique" ) ;
6162}
6263
@@ -67,7 +68,8 @@ fn reject_duplicate_namespace_priorities() {
6768 "default-priorities" : { "namespace" : [ "cpu" , "cpu" ] } ,
6869 "variants" : { "fast" : { "cpu" : { "level" : [ "v2" , "v3" ] } } , "null" : { } }
6970 } ) ;
70- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
71+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
72+ . expect_err ( "namespace priorities must be unique" ) ;
7173 assert_snapshot ! ( error, @"Variant namespace priorities must be non-empty and unique" ) ;
7274}
7375
@@ -78,7 +80,8 @@ fn reject_invalid_namespace_in_priorities() {
7880 "default-priorities" : { "namespace" : [ "CPU" ] } ,
7981 "variants" : { "fast" : { "cpu" : { "level" : [ "v2" , "v3" ] } } , "null" : { } }
8082 } ) ;
81- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
83+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
84+ . expect_err ( "namespace priorities must be valid" ) ;
8285 assert_snapshot ! ( error, @"Invalid variant namespace: `CPU`" ) ;
8386}
8487
@@ -89,7 +92,8 @@ fn reject_namespace_missing_from_priorities() {
8992 "default-priorities" : { "namespace" : [ "gpu" ] } ,
9093 "variants" : { "fast" : { "cpu" : { "level" : [ "v2" , "v3" ] } } , "null" : { } }
9194 } ) ;
92- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
95+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
96+ . expect_err ( "variant namespaces must appear in the priorities" ) ;
9397 assert_snapshot ! (
9498 error,
9599 @"Variant namespace `cpu` is missing from default-priorities.namespace"
@@ -103,7 +107,8 @@ fn reject_invalid_variant_label() {
103107 "default-priorities" : { "namespace" : [ "cpu" ] } ,
104108 "variants" : { "Bad" : { } }
105109 } ) ;
106- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
110+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
111+ . expect_err ( "variant labels must be valid" ) ;
107112 assert_snapshot ! (
108113 error,
109114 @"Variant label must contain only lowercase ASCII letters, digits, underscores, and periods, not `B`"
@@ -117,7 +122,8 @@ fn reject_invalid_variant_namespace() {
117122 "default-priorities" : { "namespace" : [ "cpu" ] } ,
118123 "variants" : { "fast" : { "CPU" : { "level" : [ "v3" ] } } , "null" : { } }
119124 } ) ;
120- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
125+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
126+ . expect_err ( "variant namespaces must be valid" ) ;
121127 assert_snapshot ! ( error, @"Invalid variant namespace: `CPU`" ) ;
122128}
123129
@@ -128,7 +134,8 @@ fn reject_invalid_variant_feature() {
128134 "default-priorities" : { "namespace" : [ "cpu" ] } ,
129135 "variants" : { "fast" : { "cpu" : { "bad.feature" : [ "v3" ] } } , "null" : { } }
130136 } ) ;
131- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
137+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
138+ . expect_err ( "variant features must be valid" ) ;
132139 assert_snapshot ! ( error, @"Invalid variant feature: `bad.feature`" ) ;
133140}
134141
@@ -139,7 +146,8 @@ fn reject_invalid_variant_value() {
139146 "default-priorities" : { "namespace" : [ "cpu" ] } ,
140147 "variants" : { "fast" : { "cpu" : { "level" : [ "v 3" ] } } , "null" : { } }
141148 } ) ;
142- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
149+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
150+ . expect_err ( "variant values must be valid" ) ;
143151 assert_snapshot ! ( error, @"Invalid variant value: `v 3`" ) ;
144152}
145153
@@ -150,7 +158,8 @@ fn reject_empty_feature_values() {
150158 "default-priorities" : { "namespace" : [ "cpu" ] } ,
151159 "variants" : { "fast" : { "cpu" : { "level" : [ ] } } , "null" : { } }
152160 } ) ;
153- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
161+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
162+ . expect_err ( "variant features must have values" ) ;
154163 assert_snapshot ! ( error, @"Variant feature `cpu :: level` must have at least one value" ) ;
155164}
156165
@@ -161,7 +170,8 @@ fn reject_duplicate_feature_values() {
161170 "default-priorities" : { "namespace" : [ "cpu" ] } ,
162171 "variants" : { "fast" : { "cpu" : { "level" : [ "v3" , "v2" , "v3" ] } } , "null" : { } }
163172 } ) ;
164- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
173+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
174+ . expect_err ( "variant values must be unique" ) ;
165175 assert_snapshot ! ( error, @"Variant feature `cpu :: level` must not contain duplicate values" ) ;
166176}
167177
@@ -172,7 +182,8 @@ fn reject_null_variant_with_properties() {
172182 "default-priorities" : { "namespace" : [ "cpu" ] } ,
173183 "variants" : { "fast" : { "cpu" : { "level" : [ "v2" , "v3" ] } } , "null" : { "cpu" : { "level" : [ "v3" ] } } }
174184 } ) ;
175- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
185+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
186+ . expect_err ( "the null variant must not have properties" ) ;
176187 assert_snapshot ! ( error, @"The null variant must not have properties" ) ;
177188}
178189
@@ -183,6 +194,7 @@ fn reject_unknown_field_in_default_priorities() {
183194 "default-priorities" : { "namespace" : [ "cpu" ] , "unknown" : [ ] } ,
184195 "variants" : { "fast" : { "cpu" : { "level" : [ "v2" , "v3" ] } } , "null" : { } }
185196 } ) ;
186- let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid) . unwrap_err ( ) ;
197+ let error = serde_json:: from_value :: < VariantsJsonContent > ( invalid)
198+ . expect_err ( "default priorities must not contain unknown fields" ) ;
187199 assert_snapshot ! ( error, @"unknown field `unknown`, expected `namespace`" ) ;
188200}
0 commit comments