Colin Cross | 9d34f35 | 2019-11-22 16:03:51 -0800 | [diff] [blame] | 1 | // Copyright 2020 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package soongconfig |
| 16 | |
| 17 | import ( |
| 18 | "reflect" |
| 19 | "testing" |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 20 | |
| 21 | "github.com/google/blueprint/proptools" |
Colin Cross | 9d34f35 | 2019-11-22 16:03:51 -0800 | [diff] [blame] | 22 | ) |
| 23 | |
| 24 | func Test_CanonicalizeToProperty(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | arg string |
| 28 | want string |
| 29 | }{ |
| 30 | { |
| 31 | name: "lowercase", |
| 32 | arg: "board", |
| 33 | want: "board", |
| 34 | }, |
| 35 | { |
| 36 | name: "uppercase", |
| 37 | arg: "BOARD", |
| 38 | want: "BOARD", |
| 39 | }, |
| 40 | { |
| 41 | name: "numbers", |
| 42 | arg: "BOARD123", |
| 43 | want: "BOARD123", |
| 44 | }, |
| 45 | { |
| 46 | name: "underscore", |
| 47 | arg: "TARGET_BOARD", |
| 48 | want: "TARGET_BOARD", |
| 49 | }, |
| 50 | { |
| 51 | name: "dash", |
| 52 | arg: "TARGET-BOARD", |
| 53 | want: "TARGET_BOARD", |
| 54 | }, |
| 55 | { |
| 56 | name: "unicode", |
| 57 | arg: "boardĪ»", |
| 58 | want: "board_", |
| 59 | }, |
| 60 | } |
| 61 | for _, tt := range tests { |
| 62 | t.Run(tt.name, func(t *testing.T) { |
| 63 | if got := CanonicalizeToProperty(tt.arg); got != tt.want { |
| 64 | t.Errorf("canonicalizeToProperty() = %v, want %v", got, tt.want) |
| 65 | } |
| 66 | }) |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | func Test_typeForPropertyFromPropertyStruct(t *testing.T) { |
| 71 | tests := []struct { |
| 72 | name string |
| 73 | ps interface{} |
| 74 | property string |
| 75 | want string |
| 76 | }{ |
| 77 | { |
| 78 | name: "string", |
| 79 | ps: struct { |
| 80 | A string |
| 81 | }{}, |
| 82 | property: "a", |
| 83 | want: "string", |
| 84 | }, |
| 85 | { |
| 86 | name: "list", |
| 87 | ps: struct { |
| 88 | A []string |
| 89 | }{}, |
| 90 | property: "a", |
| 91 | want: "[]string", |
| 92 | }, |
| 93 | { |
| 94 | name: "missing", |
| 95 | ps: struct { |
| 96 | A []string |
| 97 | }{}, |
| 98 | property: "b", |
| 99 | want: "", |
| 100 | }, |
| 101 | { |
| 102 | name: "nested", |
| 103 | ps: struct { |
| 104 | A struct { |
| 105 | B string |
| 106 | } |
| 107 | }{}, |
| 108 | property: "a.b", |
| 109 | want: "string", |
| 110 | }, |
| 111 | { |
| 112 | name: "missing nested", |
| 113 | ps: struct { |
| 114 | A struct { |
| 115 | B string |
| 116 | } |
| 117 | }{}, |
| 118 | property: "a.c", |
| 119 | want: "", |
| 120 | }, |
| 121 | { |
| 122 | name: "not a struct", |
| 123 | ps: struct { |
| 124 | A string |
| 125 | }{}, |
| 126 | property: "a.b", |
| 127 | want: "", |
| 128 | }, |
| 129 | { |
| 130 | name: "nested pointer", |
| 131 | ps: struct { |
| 132 | A *struct { |
| 133 | B string |
| 134 | } |
| 135 | }{}, |
| 136 | property: "a.b", |
| 137 | want: "string", |
| 138 | }, |
| 139 | { |
| 140 | name: "nested interface", |
| 141 | ps: struct { |
| 142 | A interface{} |
| 143 | }{ |
| 144 | A: struct { |
| 145 | B string |
| 146 | }{}, |
| 147 | }, |
| 148 | property: "a.b", |
| 149 | want: "string", |
| 150 | }, |
| 151 | { |
| 152 | name: "nested interface pointer", |
| 153 | ps: struct { |
| 154 | A interface{} |
| 155 | }{ |
| 156 | A: &struct { |
| 157 | B string |
| 158 | }{}, |
| 159 | }, |
| 160 | property: "a.b", |
| 161 | want: "string", |
| 162 | }, |
| 163 | { |
| 164 | name: "nested interface nil pointer", |
| 165 | ps: struct { |
| 166 | A interface{} |
| 167 | }{ |
| 168 | A: (*struct { |
| 169 | B string |
| 170 | })(nil), |
| 171 | }, |
| 172 | property: "a.b", |
| 173 | want: "string", |
| 174 | }, |
| 175 | } |
| 176 | for _, tt := range tests { |
| 177 | t.Run(tt.name, func(t *testing.T) { |
| 178 | typ := typeForPropertyFromPropertyStruct(tt.ps, tt.property) |
| 179 | got := "" |
| 180 | if typ != nil { |
| 181 | got = typ.String() |
| 182 | } |
| 183 | if got != tt.want { |
| 184 | t.Errorf("typeForPropertyFromPropertyStruct() = %v, want %v", got, tt.want) |
| 185 | } |
| 186 | }) |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | func Test_createAffectablePropertiesType(t *testing.T) { |
Colin Cross | 9d34f35 | 2019-11-22 16:03:51 -0800 | [diff] [blame] | 191 | tests := []struct { |
| 192 | name string |
| 193 | affectableProperties []string |
| 194 | factoryProps interface{} |
| 195 | want string |
| 196 | }{ |
| 197 | { |
| 198 | name: "string", |
| 199 | affectableProperties: []string{"cflags"}, |
| 200 | factoryProps: struct { |
| 201 | Cflags string |
| 202 | }{}, |
| 203 | want: "*struct { Cflags string }", |
| 204 | }, |
| 205 | { |
| 206 | name: "list", |
| 207 | affectableProperties: []string{"cflags"}, |
| 208 | factoryProps: struct { |
| 209 | Cflags []string |
| 210 | }{}, |
| 211 | want: "*struct { Cflags []string }", |
| 212 | }, |
| 213 | { |
| 214 | name: "string pointer", |
| 215 | affectableProperties: []string{"cflags"}, |
| 216 | factoryProps: struct { |
| 217 | Cflags *string |
| 218 | }{}, |
| 219 | want: "*struct { Cflags *string }", |
| 220 | }, |
| 221 | { |
| 222 | name: "subset", |
| 223 | affectableProperties: []string{"cflags"}, |
| 224 | factoryProps: struct { |
| 225 | Cflags string |
| 226 | Ldflags string |
| 227 | }{}, |
| 228 | want: "*struct { Cflags string }", |
| 229 | }, |
| 230 | { |
| 231 | name: "none", |
| 232 | affectableProperties: []string{"cflags"}, |
| 233 | factoryProps: struct { |
| 234 | Ldflags string |
| 235 | }{}, |
| 236 | want: "", |
| 237 | }, |
Colin Cross | 997f27a | 2021-03-05 17:25:41 -0800 | [diff] [blame] | 238 | { |
| 239 | name: "nested", |
| 240 | affectableProperties: []string{"multilib.lib32.cflags"}, |
| 241 | factoryProps: struct { |
| 242 | Multilib struct { |
| 243 | Lib32 struct { |
| 244 | Cflags string |
| 245 | } |
| 246 | } |
| 247 | }{}, |
| 248 | want: "*struct { Multilib struct { Lib32 struct { Cflags string } } }", |
| 249 | }, |
| 250 | { |
| 251 | name: "complex", |
| 252 | affectableProperties: []string{ |
| 253 | "cflags", |
| 254 | "multilib.lib32.cflags", |
| 255 | "multilib.lib32.ldflags", |
| 256 | "multilib.lib64.cflags", |
| 257 | "multilib.lib64.ldflags", |
| 258 | "zflags", |
| 259 | }, |
| 260 | factoryProps: struct { |
| 261 | Cflags string |
| 262 | Multilib struct { |
| 263 | Lib32 struct { |
| 264 | Cflags string |
| 265 | Ldflags string |
| 266 | } |
| 267 | Lib64 struct { |
| 268 | Cflags string |
| 269 | Ldflags string |
| 270 | } |
| 271 | } |
| 272 | Zflags string |
| 273 | }{}, |
| 274 | want: "*struct { Cflags string; Multilib struct { Lib32 struct { Cflags string; Ldflags string }; Lib64 struct { Cflags string; Ldflags string } }; Zflags string }", |
| 275 | }, |
Colin Cross | 9d34f35 | 2019-11-22 16:03:51 -0800 | [diff] [blame] | 276 | } |
| 277 | for _, tt := range tests { |
| 278 | t.Run(tt.name, func(t *testing.T) { |
| 279 | typ := createAffectablePropertiesType(tt.affectableProperties, []interface{}{tt.factoryProps}) |
| 280 | got := "" |
| 281 | if typ != nil { |
| 282 | got = typ.String() |
| 283 | } |
| 284 | if !reflect.DeepEqual(got, tt.want) { |
| 285 | t.Errorf("createAffectablePropertiesType() = %v, want %v", got, tt.want) |
| 286 | } |
| 287 | }) |
| 288 | } |
| 289 | } |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 290 | |
| 291 | type properties struct { |
| 292 | A *string |
| 293 | B bool |
| 294 | } |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 295 | |
| 296 | type boolVarProps struct { |
| 297 | A *string |
| 298 | B bool |
| 299 | Conditions_default *properties |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 300 | } |
| 301 | |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 302 | type soongConfigVars struct { |
| 303 | Bool_var interface{} |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 304 | } |
| 305 | |
Cole Faust | b0a9133 | 2022-11-01 17:10:23 +0000 | [diff] [blame^] | 306 | type stringSoongConfigVars struct { |
| 307 | String_var interface{} |
| 308 | } |
| 309 | |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 310 | func Test_PropertiesToApply(t *testing.T) { |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 311 | mt, _ := newModuleType(&ModuleTypeProperties{ |
| 312 | Module_type: "foo", |
| 313 | Config_namespace: "bar", |
| 314 | Bool_variables: []string{"bool_var"}, |
| 315 | Properties: []string{"a", "b"}, |
| 316 | }) |
| 317 | boolVarPositive := &properties{ |
| 318 | A: proptools.StringPtr("A"), |
| 319 | B: true, |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 320 | } |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 321 | conditionsDefault := &properties{ |
| 322 | A: proptools.StringPtr("default"), |
| 323 | B: false, |
| 324 | } |
| 325 | actualProps := &struct { |
| 326 | Soong_config_variables soongConfigVars |
| 327 | }{ |
| 328 | Soong_config_variables: soongConfigVars{ |
| 329 | Bool_var: &boolVarProps{ |
| 330 | A: boolVarPositive.A, |
| 331 | B: boolVarPositive.B, |
| 332 | Conditions_default: conditionsDefault, |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 333 | }, |
| 334 | }, |
| 335 | } |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 336 | props := reflect.ValueOf(actualProps) |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 337 | |
| 338 | testCases := []struct { |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 339 | name string |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 340 | config SoongConfig |
| 341 | wantProps []interface{} |
| 342 | }{ |
| 343 | { |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 344 | name: "no_vendor_config", |
| 345 | config: Config(map[string]string{}), |
| 346 | wantProps: []interface{}{conditionsDefault}, |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 347 | }, |
| 348 | { |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 349 | name: "vendor_config_false", |
| 350 | config: Config(map[string]string{"bool_var": "n"}), |
| 351 | wantProps: []interface{}{conditionsDefault}, |
| 352 | }, |
| 353 | { |
| 354 | name: "bool_var_true", |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 355 | config: Config(map[string]string{"bool_var": "y"}), |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 356 | wantProps: []interface{}{boolVarPositive}, |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 357 | }, |
| 358 | } |
| 359 | |
| 360 | for _, tc := range testCases { |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 361 | gotProps, err := PropertiesToApply(mt, props, tc.config) |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 362 | if err != nil { |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 363 | t.Errorf("%s: Unexpected error in PropertiesToApply: %s", tc.name, err) |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | if !reflect.DeepEqual(gotProps, tc.wantProps) { |
Liz Kammer | 432bd59 | 2020-12-16 12:42:02 -0800 | [diff] [blame] | 367 | t.Errorf("%s: Expected %s, got %s", tc.name, tc.wantProps, gotProps) |
Liz Kammer | fe8853d | 2020-12-16 09:34:33 -0800 | [diff] [blame] | 368 | } |
| 369 | } |
| 370 | } |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 371 | |
Cole Faust | b0a9133 | 2022-11-01 17:10:23 +0000 | [diff] [blame^] | 372 | func Test_PropertiesToApply_String_Error(t *testing.T) { |
| 373 | mt, _ := newModuleType(&ModuleTypeProperties{ |
| 374 | Module_type: "foo", |
| 375 | Config_namespace: "bar", |
| 376 | Variables: []string{"string_var"}, |
| 377 | Properties: []string{"a", "b"}, |
| 378 | }) |
| 379 | mt.Variables = append(mt.Variables, &stringVariable{ |
| 380 | baseVariable: baseVariable{ |
| 381 | variable: "string_var", |
| 382 | }, |
| 383 | values: []string{"a", "b", "c"}, |
| 384 | }) |
| 385 | stringVarPositive := &properties{ |
| 386 | A: proptools.StringPtr("A"), |
| 387 | B: true, |
| 388 | } |
| 389 | conditionsDefault := &properties{ |
| 390 | A: proptools.StringPtr("default"), |
| 391 | B: false, |
| 392 | } |
| 393 | actualProps := &struct { |
| 394 | Soong_config_variables stringSoongConfigVars |
| 395 | }{ |
| 396 | Soong_config_variables: stringSoongConfigVars{ |
| 397 | String_var: &boolVarProps{ |
| 398 | A: stringVarPositive.A, |
| 399 | B: stringVarPositive.B, |
| 400 | Conditions_default: conditionsDefault, |
| 401 | }, |
| 402 | }, |
| 403 | } |
| 404 | props := reflect.ValueOf(actualProps) |
| 405 | |
| 406 | _, err := PropertiesToApply(mt, props, Config(map[string]string{ |
| 407 | "string_var": "x", |
| 408 | })) |
| 409 | expected := `Soong config property "string_var" must be one of [a b c], found "x"` |
| 410 | if err == nil { |
| 411 | t.Fatalf("Expected an error, got nil") |
| 412 | } else if err.Error() != expected { |
| 413 | t.Fatalf("Error message was not correct, expected %q, got %q", expected, err.Error()) |
| 414 | } |
| 415 | } |
| 416 | |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 417 | func Test_Bp2BuildSoongConfigDefinitions(t *testing.T) { |
| 418 | testCases := []struct { |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 419 | desc string |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 420 | defs Bp2BuildSoongConfigDefinitions |
| 421 | expected string |
| 422 | }{ |
| 423 | { |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 424 | desc: "all empty", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 425 | defs: Bp2BuildSoongConfigDefinitions{}, |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 426 | expected: `soong_config_bool_variables = {} |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 427 | |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 428 | soong_config_value_variables = {} |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 429 | |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 430 | soong_config_string_variables = {}`}, { |
| 431 | desc: "only bool", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 432 | defs: Bp2BuildSoongConfigDefinitions{ |
| 433 | BoolVars: map[string]bool{ |
| 434 | "bool_var": true, |
| 435 | }, |
| 436 | }, |
| 437 | expected: `soong_config_bool_variables = { |
| 438 | "bool_var": True, |
| 439 | } |
| 440 | |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 441 | soong_config_value_variables = {} |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 442 | |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 443 | soong_config_string_variables = {}`}, { |
| 444 | desc: "only value vars", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 445 | defs: Bp2BuildSoongConfigDefinitions{ |
| 446 | ValueVars: map[string]bool{ |
| 447 | "value_var": true, |
| 448 | }, |
| 449 | }, |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 450 | expected: `soong_config_bool_variables = {} |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 451 | |
| 452 | soong_config_value_variables = { |
| 453 | "value_var": True, |
| 454 | } |
| 455 | |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 456 | soong_config_string_variables = {}`}, { |
| 457 | desc: "only string vars", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 458 | defs: Bp2BuildSoongConfigDefinitions{ |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 459 | StringVars: map[string][]string{ |
| 460 | "string_var": []string{ |
| 461 | "choice1", |
| 462 | "choice2", |
| 463 | "choice3", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 464 | }, |
| 465 | }, |
| 466 | }, |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 467 | expected: `soong_config_bool_variables = {} |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 468 | |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 469 | soong_config_value_variables = {} |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 470 | |
| 471 | soong_config_string_variables = { |
| 472 | "string_var": [ |
| 473 | "choice1", |
| 474 | "choice2", |
| 475 | "choice3", |
| 476 | ], |
| 477 | }`}, { |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 478 | desc: "all vars", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 479 | defs: Bp2BuildSoongConfigDefinitions{ |
| 480 | BoolVars: map[string]bool{ |
| 481 | "bool_var_one": true, |
| 482 | }, |
| 483 | ValueVars: map[string]bool{ |
| 484 | "value_var_one": true, |
| 485 | "value_var_two": true, |
| 486 | }, |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 487 | StringVars: map[string][]string{ |
| 488 | "string_var_one": []string{ |
| 489 | "choice1", |
| 490 | "choice2", |
| 491 | "choice3", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 492 | }, |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 493 | "string_var_two": []string{ |
| 494 | "foo", |
| 495 | "bar", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 496 | }, |
| 497 | }, |
| 498 | }, |
| 499 | expected: `soong_config_bool_variables = { |
| 500 | "bool_var_one": True, |
| 501 | } |
| 502 | |
| 503 | soong_config_value_variables = { |
| 504 | "value_var_one": True, |
| 505 | "value_var_two": True, |
| 506 | } |
| 507 | |
| 508 | soong_config_string_variables = { |
| 509 | "string_var_one": [ |
| 510 | "choice1", |
| 511 | "choice2", |
| 512 | "choice3", |
| 513 | ], |
| 514 | "string_var_two": [ |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 515 | "foo", |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 516 | "bar", |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 517 | ], |
| 518 | }`}, |
| 519 | } |
| 520 | for _, test := range testCases { |
Liz Kammer | 72beb34 | 2022-02-03 08:42:10 -0500 | [diff] [blame] | 521 | t.Run(test.desc, func(t *testing.T) { |
| 522 | actual := test.defs.String() |
| 523 | if actual != test.expected { |
| 524 | t.Errorf("Expected:\n%s\nbut got:\n%s", test.expected, actual) |
| 525 | } |
| 526 | }) |
Jingwen Chen | 0181202 | 2021-11-19 14:29:43 +0000 | [diff] [blame] | 527 | } |
| 528 | } |