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

Function TestDefaultNull

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

Source from the content-addressed store, hash-verified

605}
606
607func TestDefaultNull(t *testing.T) {
608 configDataEmpty := MustReadYAMLStr(``)
609 configDataNull := MustReadYAMLStr(`Null`)
610 configDataEmptyMap := MustReadYAMLStr(`{}`)
611 configDataNullValues := MustReadYAMLStr(
612 `
613 key1: null
614 key2: null
615 key3: null
616 `)
617 configDataParentNullValues := MustReadYAMLStr(
618 `
619 key_a:
620 key1: null
621 key2: null
622 key3: null
623 `)
624 configDataParentNull := MustReadYAMLStr(
625 `
626 key_a: null
627 `)
628
629 structFieldValidations := []*StructFieldValidation{
630 {
631 StructField: "Key1",
632 StringPtrValidation: &StringPtrValidation{
633 AllowExplicitNull: true,
634 },
635 },
636 {
637 StructField: "Key2",
638 StringListValidation: &StringListValidation{
639 Default: []string{"key2"},
640 AllowExplicitNull: true,
641 },
642 },
643 {
644 StructField: "Key3",
645 InterfaceValidation: &InterfaceValidation{
646 Default: "key3",
647 AllowExplicitNull: true,
648 },
649 },
650 }
651
652 // AllowExplicitNull = true
653
654 structValidation := &StructValidation{
655 StructFieldValidations: structFieldValidations,
656 AllowExplicitNull: true,
657 }
658
659 var expected interface{}
660
661 expected = &NullableConfig{}
662 testConfig(structValidation, configDataEmpty, expected, t)
663 testConfig(structValidation, configDataNull, expected, t)
664

Callers

nothing calls this directly

Calls 3

MustReadYAMLStrFunction · 0.85
testConfigFunction · 0.85
testConfigErrorFunction · 0.85

Tested by

no test coverage detected