Example #1
0
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)
		}),
	)
}
Example #2
0
func TestAalmss(t *testing.T) {
	ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil)
	Run(t, ctx, `{
			"type": "multi",
			"aalmss": [{"a": "b", "c": "d"}, {"e": "f", "g": "h"}]
		}`,
		TestValue(func(t *testing.T, v interface{}) {
			require.Len(t, v.(*data.Multi).Aalmss, 2)
			require.Len(t, v.(*data.Multi).Aalmss[0], 2)
			require.Len(t, v.(*data.Multi).Aalmss[1], 2)
			assert.Equal(t, "b", v.(*data.Multi).Aalmss[0]["a"].Value())
			assert.Equal(t, "d", v.(*data.Multi).Aalmss[0]["c"].Value())
			assert.Equal(t, "f", v.(*data.Multi).Aalmss[1]["e"].Value())
			assert.Equal(t, "h", v.(*data.Multi).Aalmss[1]["g"].Value())
		}),
	)
}
Example #3
0
func TestAalajs(t *testing.T) {
	ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil)
	Run(t, ctx, `{
			"type": "multi",
			"aalajs": [["a", "b"],["c", "d"]]
		}`,
		TestValue(func(t *testing.T, v interface{}) {
			require.Len(t, v.(*data.Multi).Aalajs, 2)
			require.Len(t, v.(*data.Multi).Aalajs[0], 2)
			require.Len(t, v.(*data.Multi).Aalajs[1], 2)
			assert.Equal(t, "a", v.(*data.Multi).Aalajs[0][0])
			assert.Equal(t, "b", v.(*data.Multi).Aalajs[0][1])
			assert.Equal(t, "c", v.(*data.Multi).Aalajs[1][0])
			assert.Equal(t, "d", v.(*data.Multi).Aalajs[1][1])
		}),
	)
}
Example #4
0
func TestMalass(t *testing.T) {
	ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil)
	Run(t, ctx, `{
			"type": "multi",
			"malass": {"a": ["b", "c"], "d": ["e", "f"]}
		}`,
		TestValue(func(t *testing.T, v interface{}) {
			require.Len(t, v.(*data.Multi).Malass, 2)
			require.Len(t, v.(*data.Multi).Malass["a"], 2)
			require.Len(t, v.(*data.Multi).Malass["d"], 2)
			assert.Equal(t, "b", v.(*data.Multi).Malass["a"][0].Value())
			assert.Equal(t, "c", v.(*data.Multi).Malass["a"][1].Value())
			assert.Equal(t, "e", v.(*data.Multi).Malass["d"][0].Value())
			assert.Equal(t, "f", v.(*data.Multi).Malass["d"][1].Value())
		}),
	)
}
Example #5
0
func TestAalas(t *testing.T) {
	ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil)
	Run(t, ctx, `{
			"type": "multi",
			"aalas": [
				[{"type": "simple", "js": "a"}, {"type": "simple", "js": "b"}],
				[{"type": "simple", "js": "c"}, {"type": "simple", "js": "d"}]
			]
		}`,
		TestValue(func(t *testing.T, v interface{}) {
			require.Len(t, v.(*data.Multi).Aalas, 2)
			require.Len(t, v.(*data.Multi).Aalas[0], 2)
			require.Len(t, v.(*data.Multi).Aalas[1], 2)
			assert.Equal(t, "a", v.(*data.Multi).Aalas[0][0].Js)
			assert.Equal(t, "b", v.(*data.Multi).Aalas[0][1].Js)
			assert.Equal(t, "c", v.(*data.Multi).Aalas[1][0].Js)
			assert.Equal(t, "d", v.(*data.Multi).Aalas[1][1].Js)
		}),
	)
}
Example #6
0
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())
		}),
	)
}
Example #7
0
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])
		}),
	)
}
Example #8
0
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])
		}),
	)
}
Example #9
0
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"])
		}),
	)
}
Example #10
0
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())
		}),
	)
}
Example #11
0
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"])
		}),
	)
}
Example #12
0
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"])
		}),
	)
}
Example #13
0
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())
		}),
	)
}
Example #14
0
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())
		}),
	)
}
Example #15
0
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)
		}),
	)
}
Example #16
0
func TestAi(t *testing.T) {
	ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil)
	Run(t, ctx, `{
			"type": "multi",
			"ai": [{
				"type": "facea",
				"a": "a1"
			},{
				"type": "faceb",
				"b": "b1"
			}]
		}`,
		TestValue(func(t *testing.T, v interface{}) {
			require.Len(t, v.(*data.Multi).Ai, 2)
			assert.Equal(t, "a1", v.(*data.Multi).Ai[0].Face())
			assert.Equal(t, "b1", v.(*data.Multi).Ai[1].Face())
		}),
	)
}
Example #17
0
func TestAm(t *testing.T) {
	ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil)
	Run(t, ctx, `{
			"type": "multi",
			"am": [{
				"type": "multi",
				"js": "a"
			},{
				"type": "multi",
				"js": "b"
			}]
		}`,
		TestValue(func(t *testing.T, v interface{}) {
			require.Len(t, v.(*data.Multi).Am, 2)
			assert.Equal(t, "a", v.(*data.Multi).Am[0].Js)
			assert.Equal(t, "b", v.(*data.Multi).Am[1].Js)
		}),
	)
}
Example #18
0
func TestAri(t *testing.T) {
	ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil)
	Run(t, ctx, `{
			"type": "multi",
			"ari": [{
				"type": "system:@string",
				"max-length": 2
			},{
				"type": "system:@bool",
				"default": true
			}]
		}`,
		TestValue(func(t *testing.T, v interface{}) {
			require.Len(t, v.(*data.Multi).Ari, 2)
			assert.Equal(t, 2, v.(*data.Multi).Ari[0].(*system.StringRule).MaxLength.Value())
			assert.Equal(t, true, v.(*data.Multi).Ari[1].(*system.BoolRule).Default.Value())
		}),
	)
}
Example #19
0
func TestMnri(t *testing.T) {
	ctx := ke.NewContext(context.Background(), "kego.io/tests/data", nil)
	Run(t, ctx, `{
			"type": "multi",
			"mnri": {
				"a": "a",
				"b": {"type": "system:int", "value": 1},
				"c": {"type": "alajs", "value": ["a", "b", "c"]},
				"d": {"type": "almjs", "value": {"a": "b", "c": "d"}}
			}
		}`,
		TestValue(func(t *testing.T, v interface{}) {
			require.Len(t, v.(*data.Multi).Mnri, 4)
			assert.Equal(t, "a", v.(*data.Multi).Mnri["a"].GetString(ctx).Value())
			assert.Equal(t, "1", v.(*data.Multi).Mnri["b"].GetString(ctx).Value())
			assert.Equal(t, "abc", v.(*data.Multi).Mnri["c"].GetString(ctx).Value())
			assert.Equal(t, "abcd", v.(*data.Multi).Mnri["d"].GetString(ctx).Value())
		}),
	)
}