Merge pull request #514 from unistack-org/cleanup
remove mock data from memory registry
This commit is contained in:
		
							
								
								
									
										51
									
								
								broker/common_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								broker/common_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | |||||||
|  | package broker | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/micro/go-micro/registry" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | var ( | ||||||
|  | 	// mock data | ||||||
|  | 	testData = map[string][]*registry.Service{ | ||||||
|  | 		"foo": []*registry.Service{ | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.0", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.0-123", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    9999, | ||||||
|  | 					}, | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.0-321", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    9999, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.1", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.1-321", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    6666, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.3", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.3-345", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    8888, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 	} | ||||||
|  | ) | ||||||
| @@ -14,7 +14,7 @@ import ( | |||||||
| func newTestRegistry() *memory.Registry { | func newTestRegistry() *memory.Registry { | ||||||
| 	r := memory.NewRegistry() | 	r := memory.NewRegistry() | ||||||
| 	m := r.(*memory.Registry) | 	m := r.(*memory.Registry) | ||||||
| 	m.Setup() | 	m.Services = testData | ||||||
| 	return m | 	return m | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										51
									
								
								client/common_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								client/common_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | |||||||
|  | package client | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/micro/go-micro/registry" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | var ( | ||||||
|  | 	// mock data | ||||||
|  | 	testData = map[string][]*registry.Service{ | ||||||
|  | 		"foo": []*registry.Service{ | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.0", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.0-123", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    9999, | ||||||
|  | 					}, | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.0-321", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    9999, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.1", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.1-321", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    6666, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.3", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.3-345", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    8888, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 	} | ||||||
|  | ) | ||||||
| @@ -13,8 +13,9 @@ import ( | |||||||
|  |  | ||||||
| func newTestRegistry() registry.Registry { | func newTestRegistry() registry.Registry { | ||||||
| 	r := memory.NewRegistry() | 	r := memory.NewRegistry() | ||||||
| 	r.(*memory.Registry).Setup() | 	reg := r.(*memory.Registry) | ||||||
| 	return r | 	reg.Services = testData | ||||||
|  | 	return reg | ||||||
| } | } | ||||||
|  |  | ||||||
| func TestCallAddress(t *testing.T) { | func TestCallAddress(t *testing.T) { | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| package memory | package micro | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"github.com/micro/go-micro/registry" | 	"github.com/micro/go-micro/registry" | ||||||
| @@ -6,7 +6,7 @@ import ( | |||||||
| 
 | 
 | ||||||
| var ( | var ( | ||||||
| 	// mock data | 	// mock data | ||||||
| 	Data = map[string][]*registry.Service{ | 	testData = map[string][]*registry.Service{ | ||||||
| 		"foo": []*registry.Service{ | 		"foo": []*registry.Service{ | ||||||
| 			{ | 			{ | ||||||
| 				Name:    "foo", | 				Name:    "foo", | ||||||
| @@ -14,7 +14,7 @@ func TestFunction(t *testing.T) { | |||||||
| 	wg.Add(1) | 	wg.Add(1) | ||||||
|  |  | ||||||
| 	r := memory.NewRegistry() | 	r := memory.NewRegistry() | ||||||
| 	r.(*memory.Registry).Setup() | 	r.(*memory.Registry).Services = testData | ||||||
|  |  | ||||||
| 	// create service | 	// create service | ||||||
| 	fn := NewFunction( | 	fn := NewFunction( | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ var ( | |||||||
| 	timeout = time.Millisecond * 10 | 	timeout = time.Millisecond * 10 | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | /* | ||||||
| // Setup sets mock data | // Setup sets mock data | ||||||
| func (m *Registry) Setup() { | func (m *Registry) Setup() { | ||||||
| 	m.Lock() | 	m.Lock() | ||||||
| @@ -30,6 +31,7 @@ func (m *Registry) Setup() { | |||||||
| 	// add some memory data | 	// add some memory data | ||||||
| 	m.Services = Data | 	m.Services = Data | ||||||
| } | } | ||||||
|  | */ | ||||||
|  |  | ||||||
| func (m *Registry) watch(r *registry.Result) { | func (m *Registry) watch(r *registry.Result) { | ||||||
| 	var watchers []*Watcher | 	var watchers []*Watcher | ||||||
|   | |||||||
							
								
								
									
										51
									
								
								selector/common_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								selector/common_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | |||||||
|  | package selector | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"github.com/micro/go-micro/registry" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | var ( | ||||||
|  | 	// mock data | ||||||
|  | 	testData = map[string][]*registry.Service{ | ||||||
|  | 		"foo": []*registry.Service{ | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.0", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.0-123", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    9999, | ||||||
|  | 					}, | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.0-321", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    9999, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.1", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.1-321", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    6666, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 			{ | ||||||
|  | 				Name:    "foo", | ||||||
|  | 				Version: "1.0.3", | ||||||
|  | 				Nodes: []*registry.Node{ | ||||||
|  | 					{ | ||||||
|  | 						Id:      "foo-1.0.3-345", | ||||||
|  | 						Address: "localhost", | ||||||
|  | 						Port:    8888, | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
|  | 	} | ||||||
|  | ) | ||||||
| @@ -10,7 +10,8 @@ func TestRegistrySelector(t *testing.T) { | |||||||
| 	counts := map[string]int{} | 	counts := map[string]int{} | ||||||
|  |  | ||||||
| 	r := memory.NewRegistry() | 	r := memory.NewRegistry() | ||||||
| 	r.(*memory.Registry).Setup() | 	rg := r.(*memory.Registry) | ||||||
|  | 	rg.Services = testData | ||||||
| 	cache := NewSelector(Registry(r)) | 	cache := NewSelector(Registry(r)) | ||||||
|  |  | ||||||
| 	next, err := cache.Select("foo") | 	next, err := cache.Select("foo") | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ func testService(ctx context.Context, wg *sync.WaitGroup, name string) Service { | |||||||
| 	wg.Add(1) | 	wg.Add(1) | ||||||
|  |  | ||||||
| 	r := memory.NewRegistry() | 	r := memory.NewRegistry() | ||||||
| 	r.(*memory.Registry).Setup() | 	r.(*memory.Registry).Services = testData | ||||||
|  |  | ||||||
| 	// create service | 	// create service | ||||||
| 	return NewService( | 	return NewService( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user