luis 7 rokov pred
rodič
commit
70a71cf606

+ 2 - 2
go/src/flow/internal/assert/assert.go

@@ -36,7 +36,7 @@ type Checker struct {
 
 //Eq check if equal
 func (t *Checker) Eq(a, b interface{}, params ...interface{}) *Checker {
-	msg := fmt.Sprintf("(%s) Expect Eq '%v' got '%v'", fmt.Sprint(params...), a, b)
+	msg := fmt.Sprintf("(%s) Expect Eq '%v' got '%v'", fmt.Sprint(params...), b, a)
 
 	if (a == nil || (reflect.ValueOf(a).Kind() == reflect.Ptr && reflect.ValueOf(a).IsNil())) &&
 		(b == nil || (reflect.ValueOf(b).Kind() == reflect.Ptr && reflect.ValueOf(b).IsNil())) {
@@ -52,7 +52,7 @@ func (t *Checker) Eq(a, b interface{}, params ...interface{}) *Checker {
 
 //NotEq check if different
 func (t *Checker) NotEq(a, b interface{}, params ...interface{}) *Checker {
-	msg := fmt.Sprintf("(%s) Expect NotEq '%v' got '%v'", fmt.Sprint(params...), a, b)
+	msg := fmt.Sprintf("(%s) Expect NotEq '%v' got '%v'", fmt.Sprint(params...), b, a)
 	if (a == nil || (reflect.ValueOf(a).Kind() == reflect.Ptr && reflect.ValueOf(a).IsNil())) &&
 		(b == nil || (reflect.ValueOf(b).Kind() == reflect.Ptr && reflect.ValueOf(b).IsNil())) {
 		t.fail(msg)

+ 5 - 5
go/src/flow/registry/entry_test.go

@@ -24,9 +24,9 @@ func TestDescription(t *testing.T) {
 	r := registry.New()
 
 	e := registry.NewEntry(r, func() int { return 0 })
-	e.Categories("a", "b")
+	e.Tags("a", "b")
 	a.Eq(e.Err(), nil, "should not fail setting categories")
-	a.Eq(len(e.Description.Categories), 2, "should have 2 categories")
+	a.Eq(len(e.Description.Tags), 2, "should have 2 categories")
 
 	e.DescInput(0, "input doc")
 	a.Eq(e.Err(), nil, "should not fail setting input description")
@@ -45,7 +45,7 @@ func TestDescriptionError(t *testing.T) {
 	r := registry.New()
 	e := registry.NewEntry(r, "string")
 	a.Eq(e.Err(), registry.ErrNotAFunc, "entry is not a function")
-	e.Categories("a", "b")
+	e.Tags("a", "b")
 	a.Eq(e.Err(), registry.ErrNotAFunc, "entry is not a function")
 	e.DescInput(0, "input doc")
 	a.Eq(e.Err(), registry.ErrNotAFunc, "entry is not a function")
@@ -64,12 +64,12 @@ func TestEntryBatch(t *testing.T) {
 		registry.NewEntry(r, func() int { return 0 }),
 		registry.NewEntry(r, func() int { return 0 }),
 		registry.NewEntry(r, func() int { return 0 }),
-	}.Categories("test").
+	}.Tags("test").
 		Extra("name", 1)
 
 	a.Eq(len(b), 3, "should have 3 items")
 	for _, e := range b {
-		a.Eq(e.Description.Categories[0], "test", "It should be of category test")
+		a.Eq(e.Description.Tags[0], "test", "It should be of category test")
 		a.Eq(e.Description.Extra["name"], 1, "It should contain extra")
 	}
 

+ 34 - 0
go/src/flow/registry/registry_test.go

@@ -134,6 +134,40 @@ func TestDescriptions(t *testing.T) {
 	a.Eq(len(d), 2, "should contain 2 descriptions")
 
 	t.Log(d)
+}
+func TestClone(t *testing.T) {
+	a := assert.A(t)
+	r := registry.New()
+	r.Register("vecadd", dummy1)
+
+	d, err := r.Descriptions()
+	a.Eq(err, nil, "should not error fetching description")
+
+	a.Eq(len(d), 1, "should contain 1 descriptions")
+
+	r2 := r.Clone()
+	r2.Register("vecmul", dummy2)
+	a.Eq(len(d), 1, "should contain 1 descriptions")
+
+	d2, err := r2.Descriptions()
+	a.Eq(err, nil, "should not error fetching descriptions")
+
+	a.Eq(len(d2), 2, "should contain 2 descriptions")
+	_, ok := d2["vecmul"]
+	a.Eq(ok, true, "should be equal")
+}
+
+func TestAddEntry(t *testing.T) {
+	a := assert.A(t)
+	r := registry.New()
+	g := r.Add(r.Register("vecadd", dummy1))
+	a.Eq(len(g), 1, "should contain 1 entry")
+
+	r.Add(dummy2)
+
+	d, err := r.Descriptions()
+	a.Eq(err, nil, "should not error fetching descriptions")
+	a.Eq(len(d), 2, "should contain 2 descriptions")
 
 }