func TestMalms(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "malms": { "a": { "b": {"type":"simple", "js": "c"}, "d": {"type":"simple", "js": "e"} }, "f": { "g": {"type":"simple", "js": "h"}, "i": {"type":"simple", "js": "j"} } } }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Malms, 2) require.Len(t, v.(*data.Multi).Malms["a"], 2) require.Len(t, v.(*data.Multi).Malms["f"], 2) assert.Equal(t, "c", v.(*data.Multi).Malms["a"]["b"].Js) assert.Equal(t, "e", v.(*data.Multi).Malms["a"]["d"].Js) assert.Equal(t, "h", v.(*data.Multi).Malms["f"]["g"].Js) assert.Equal(t, "j", v.(*data.Multi).Malms["f"]["i"].Js) }), ) }
func TestRi(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "ri": {"type": "system:@string", "default": "a"} }`, TestValue(func(t *testing.T, v interface{}) { assert.Equal(t, "a", v.(*data.Multi).Ri.(*system.StringRule).Default.Value()) }), ) }
func TestSp(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "sp": {"type": "system:package", "recursive": true} }`, TestValue(func(t *testing.T, v interface{}) { assert.Equal(t, true, v.(*data.Multi).Sp.Recursive) }), ) }
func TestNri2(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "nri": {"type": "aljn2", "value": 1.1} }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).Nri) assert.Equal(t, 1.1, v.(*data.Multi).Nri.GetNumber(ctx).Value()) }), ) }
func TestSri2(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "sri": {"type": "aljs2", "value": "a"} }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).Sri) assert.Equal(t, "a", v.(*data.Multi).Sri.GetString(ctx).Value()) }), ) }
func TestI(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "i": {"type": "facea", "a": "b"} }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).I) assert.Equal(t, "b", v.(*data.Multi).I.Face()) }), ) }
func TestBri2(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "bri": {"type": "aljb2", "value": true} }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).Bri) assert.Equal(t, true, v.(*data.Multi).Bri.GetBool(ctx).Value()) }), ) }
func TestAljn(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "aljn": 1.1 }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).Aljn) assert.Equal(t, 1.1, v.(*data.Multi).Aljn.Value()) }), ) }
func TestAls(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "als": {"type": "als", "js": "a"} }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).Als) assert.Equal(t, "a", v.(*data.Multi).Als.Js) }), ) }
func TestSr(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "sr": "a" }`, TestValue(func(t *testing.T, v interface{}) { assert.Equal(t, "kego.io/tests/data", v.(*data.Multi).Sr.Package) assert.Equal(t, "a", v.(*data.Multi).Sr.Name) }), ) }
func TestAljbi(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "aljbi": true }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).Aljbi.GetAljb(ctx)) assert.IsType(t, new(data.Aljb), v.(*data.Multi).Aljbi) assert.Equal(t, true, v.(*data.Multi).Aljbi.GetAljb(ctx).Value()) }), ) }
func TestAjb(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "ajb": [true, false] }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Ajb, 2) assert.Equal(t, true, v.(*data.Multi).Ajb[0]) assert.Equal(t, false, v.(*data.Multi).Ajb[1]) }), ) }
func TestAjn(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "ajn": [1.1, 1.2] }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Ajn, 2) assert.Equal(t, 1.1, v.(*data.Multi).Ajn[0]) assert.Equal(t, 1.2, v.(*data.Multi).Ajn[1]) }), ) }
func TestAalss(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "aalss": ["a", "b"] }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Aalss, 2) assert.Equal(t, "a", v.(*data.Multi).Aalss[0].Value()) assert.Equal(t, "b", v.(*data.Multi).Aalss[1].Value()) }), ) }
func TestMjb(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "mjb": {"a": true, "b": false} }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Mjb, 2) assert.Equal(t, true, v.(*data.Multi).Mjb["a"]) assert.Equal(t, false, v.(*data.Multi).Mjb["b"]) }), ) }
func TestMjn(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "mjn": {"a": 1.1, "b": 1.2} }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Mjn, 2) assert.Equal(t, 1.1, v.(*data.Multi).Mjn["a"]) assert.Equal(t, 1.2, v.(*data.Multi).Mjn["b"]) }), ) }
func TestAsi(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "asi": [2, 3] }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Asi, 2) assert.Equal(t, 2, v.(*data.Multi).Asi[0].Value()) assert.Equal(t, 3, v.(*data.Multi).Asi[1].Value()) }), ) }
func TestMsi(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "msi": {"a": 2, "b": 3} }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Msi, 2) assert.Equal(t, 2, v.(*data.Multi).Msi["a"].Value()) assert.Equal(t, 3, v.(*data.Multi).Msi["b"].Value()) }), ) }
func TestMjs(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "mjs": {"a": "b", "c": "d"} }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Mjs, 2) assert.Equal(t, "b", v.(*data.Multi).Mjs["a"]) assert.Equal(t, "d", v.(*data.Multi).Mjs["c"]) }), ) }
func TestMsr(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "msr": {"a": "a", "b": "system:b"} }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Msr, 2) assert.Equal(t, "kego.io/tests/data:a", v.(*data.Multi).Msr["a"].Value()) assert.Equal(t, "kego.io/system:b", v.(*data.Multi).Msr["b"].Value()) }), ) }
func TestAlmjsiError(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) // Note: map alias types in interfaces are always marshalled to explicit // object notation, so this throws an error. Run(t, ctx, `{ "type": "multi", "almjsi": {"a": "b", "c": "d"} }`, UnmarshalError(func(t *testing.T, err error) { require.IsError(t, err, "SVXYHJWMOC") require.HasError(t, err, "RXEPCCGFKV") }), ) }
func TestAlsError(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) // Type must be als when unpacking into als, even if it's an alias // of simple Run(t, ctx, `{ "type": "multi", "als": {"type": "simple", "js": "a"} }`, UnmarshalError(func(t *testing.T, err error) { require.IsError(t, err, "SVXYHJWMOC") require.HasError(t, err, "BNHVLQPFKC") }), ) }
func TestAlmjsi(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) // Note: map alias types in interfaces are always marshalled to explicit // object notation. Run(t, ctx, `{ "type": "multi", "almjsi": {"type": "almjs", "value": {"a": "b", "c": "d"}} }`, TestValue(func(t *testing.T, v interface{}) { assert.Len(t, v.(*data.Multi).Almjsi.GetAlmjs(ctx), 2) assert.Equal(t, "b", v.(*data.Multi).Almjsi.GetAlmjs(ctx)["a"]) assert.Equal(t, "d", v.(*data.Multi).Almjsi.GetAlmjs(ctx)["c"]) }), ) }
func TestAljni2(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) // Aljn2 is another alias number type that implements the Aljn default // interface. Run(t, ctx, `{ "type": "multi", "aljni": {"type": "aljn2", "value": 1.1} }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).Aljni.GetAljn(ctx)) assert.IsType(t, new(data.Aljn2), v.(*data.Multi).Aljni) assert.Equal(t, 1.1, v.(*data.Multi).Aljni.GetAljn(ctx).Value()) }), ) }
func TestAljbi2(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) // aljb2 is another alias bool type that implements the aljb default // interface. Run(t, ctx, `{ "type": "multi", "aljbi": {"type": "aljb2", "value": true} }`, TestValue(func(t *testing.T, v interface{}) { assert.NotNil(t, v.(*data.Multi).Aljbi.GetAljb(ctx)) assert.IsType(t, new(data.Aljb2), v.(*data.Multi).Aljbi) assert.Equal(t, true, v.(*data.Multi).Aljbi.GetAljb(ctx).Value()) }), ) }
func TestJbJnJs(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "jb": true, "jn": 1.1, "js": "a" }`, TestValue(func(t *testing.T, v interface{}) { assert.Equal(t, true, v.(*data.Multi).Jb) assert.Equal(t, 1.1, v.(*data.Multi).Jn) assert.Equal(t, "a", v.(*data.Multi).Js) }), ) }
func TestSbSnSs(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "sb": true, "sn": 1.1, "ss": "a" }`, TestValue(func(t *testing.T, v interface{}) { assert.Equal(t, true, v.(*data.Multi).Sb.Value()) assert.Equal(t, 1.1, v.(*data.Multi).Sn.Value()) assert.Equal(t, "a", v.(*data.Multi).Ss.Value()) }), ) }
func TestAlajsi(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) // Note: array alias types in an interface can be expressed without // explicit type notation. Run(t, ctx, `{ "type": "multi", "alajsi": ["a", "b"] }`, TestValue(func(t *testing.T, v interface{}) { assert.Len(t, v.(*data.Multi).Alajsi.GetAlajs(ctx), 2) assert.Equal(t, "a", v.(*data.Multi).Alajsi.GetAlajs(ctx)[0]) assert.Equal(t, "b", v.(*data.Multi).Alajsi.GetAlajs(ctx)[1]) }), ) }
func TestAlas(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "alas": [ {"type":"simple", "js": "a"}, {"type":"simple", "js": "b"} ] }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Alas, 2) assert.Equal(t, "a", v.(*data.Multi).Alas[0].Js) assert.Equal(t, "b", v.(*data.Multi).Alas[1].Js) }), ) }
func TestMsp(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil) Run(t, ctx, `{ "type": "multi", "msp": { "a": {"type": "system:package", "recursive": true}, "b": {"type": "system:package"} } }`, TestValue(func(t *testing.T, v interface{}) { require.Len(t, v.(*data.Multi).Msp, 2) assert.Equal(t, true, v.(*data.Multi).Msp["a"].Recursive) assert.Equal(t, false, v.(*data.Multi).Msp["b"].Recursive) }), ) }