github.com/moleculer-go/moleculer@v0.3.3/registry/node_test.go (about) 1 package registry 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 func TestFilterServices(t *testing.T) { 9 currentServices := []map[string]interface{}{ 10 {"name": "service1"}, 11 {"name": "service2"}, 12 {"name": "service3"}, 13 } 14 info := map[string]interface{}{ 15 "services": []interface{}{ 16 map[string]interface{}{"name": "service1"}, 17 map[string]interface{}{"name": "$service4"}, 18 map[string]interface{}{"name": "service5"}, 19 }, 20 } 21 22 services, removedServices := FilterServices(currentServices, info) 23 24 expectedServices := []map[string]interface{}{ 25 {"name": "service1"}, 26 {"name": "service5"}, 27 } 28 if !reflect.DeepEqual(services, expectedServices) { 29 t.Errorf("Expected services %v, but got %v", expectedServices, services) 30 } 31 32 expectedRemovedServices := []map[string]interface{}{ 33 {"name": "service2"}, 34 {"name": "service3"}, 35 } 36 if !reflect.DeepEqual(removedServices, expectedRemovedServices) { 37 t.Errorf("Expected removed services %v, but got %v", expectedRemovedServices, removedServices) 38 } 39 }