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

Function TestDefaultField

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

Source from the content-addressed store, hash-verified

858}
859
860func TestDefaultField(t *testing.T) {
861 structValidation := &StructValidation{
862 StructFieldValidations: []*StructFieldValidation{
863 {
864 StructField: "Key1",
865 BoolValidation: &BoolValidation{},
866 },
867 {
868 StructField: "Key2",
869 StringValidation: &StringValidation{},
870 },
871 {
872 StructField: "Key3",
873 DefaultField: "Key2",
874 StringValidation: &StringValidation{},
875 },
876 },
877 }
878
879 configData := MustReadYAMLStr(
880 `
881 key1: true
882 key2: "key2"
883 key3: "key3"
884 `)
885 expected := &DefaultConfig{
886 Key1: true,
887 Key2: "key2",
888 Key3: "key3",
889 }
890 testConfig(structValidation, configData, expected, t)
891
892 configData = MustReadYAMLStr(
893 `
894 key1: true
895 key2: "key2"
896 `)
897 expected = &DefaultConfig{
898 Key1: true,
899 Key2: "key2",
900 Key3: "key2",
901 }
902 testConfig(structValidation, configData, expected, t)
903
904 structValidation = &StructValidation{
905 StructFieldValidations: []*StructFieldValidation{
906 {
907 StructField: "Key1",
908 BoolValidation: &BoolValidation{},
909 },
910 {
911 StructField: "Key2",
912 StringValidation: &StringValidation{},
913 },
914 {
915 StructField: "Key3",
916 DefaultDependentFields: []string{"Key2"},
917 DefaultDependentFieldsFunc: func(vals []interface{}) interface{} {

Callers

nothing calls this directly

Calls 2

MustReadYAMLStrFunction · 0.85
testConfigFunction · 0.85

Tested by

no test coverage detected