MCPcopy
hub / github.com/cortexlabs/cortex / TestInterface

Function TestInterface

pkg/lib/configreader/reader_test.go:423–495  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

421}
422
423func TestInterface(t *testing.T) {
424 structValidation := &StructValidation{
425 StructFieldValidations: []*StructFieldValidation{
426 {
427 // Key: "typed",
428 StructField: "Typed",
429 InterfaceStructValidation: _interfaceStructValidation,
430 },
431 },
432 }
433
434 configDataType1 := MustReadYAMLStr(
435 `
436 typed:
437 type: type1
438 key0: testA
439 key1: testB
440 `)
441
442 configDataType2 := MustReadYAMLStr(
443 `
444 typed:
445 type: type2
446 keyA: 0
447 keyB: 1
448 `)
449
450 expectedType1 := &TypedConfig{
451 Typed: &Typed1{
452 Key0: "testA",
453 Key1: "testB",
454 },
455 }
456
457 expectedType2 := &TypedConfig{
458 Typed: &Typed2{
459 KeyA: 0,
460 KeyB: 1,
461 },
462 }
463
464 testConfig(structValidation, configDataType1, expectedType1, t)
465 testConfig(structValidation, configDataType2, expectedType2, t)
466
467 structValidation = &StructValidation{
468 StructFieldValidations: []*StructFieldValidation{
469 {
470 // Key: "typed",
471 StructField: "Typed",
472 InterfaceStructValidation: _interfaceStructValidationWithTypeKeyConfig,
473 },
474 },
475 }
476
477 expectedTypeWithTypeKey1 := &TypedConfig{
478 Typed: &Typed1WithType{
479 Type: "type1",
480 Key0: "testA",

Callers

nothing calls this directly

Calls 2

MustReadYAMLStrFunction · 0.85
testConfigFunction · 0.85

Tested by

no test coverage detected