Skip to content

Commit

Permalink
move test data
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed Nov 16, 2019
1 parent 90d7a87 commit eeed493
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (

proto "github.com/micro/go-micro/debug/proto"
"github.com/micro/go-micro/registry/memory"
"github.com/micro/go-micro/util/test"
)

func TestFunction(t *testing.T) {
var wg sync.WaitGroup
wg.Add(1)

r := memory.NewRegistry(memory.Services(testData))
r := memory.NewRegistry(memory.Services(test.Data))

// create service
fn := NewFunction(
Expand Down
2 changes: 1 addition & 1 deletion service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/micro/go-micro/debug/profile/pprof"
"github.com/micro/go-micro/plugin"
"github.com/micro/go-micro/server"
"github.com/micro/go-micro/util/wrapper"
"github.com/micro/go-micro/util/log"
"github.com/micro/go-micro/util/wrapper"
)

type service struct {
Expand Down
3 changes: 2 additions & 1 deletion service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
proto "github.com/micro/go-micro/debug/proto"
"github.com/micro/go-micro/registry/memory"
"github.com/micro/go-micro/util/log"
"github.com/micro/go-micro/util/test"
)

func testShutdown(wg *sync.WaitGroup, cancel func()) {
Expand All @@ -29,7 +30,7 @@ func testService(ctx context.Context, wg *sync.WaitGroup, name string) Service {
// add self
wg.Add(1)

r := memory.NewRegistry(memory.Services(testData))
r := memory.NewRegistry(memory.Services(test.Data))

// create service
return NewService(
Expand Down
6 changes: 3 additions & 3 deletions common_test.go → util/test/test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package micro
package test

import (
"github.com/micro/go-micro/registry"
)

var (
// mock data
testData = map[string][]*registry.Service{
// mock registry data
Data = map[string][]*registry.Service{
"foo": {
{
Name: "foo",
Expand Down
10 changes: 5 additions & 5 deletions util/wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func (c *clientWrapper) Publish(ctx context.Context, p client.Message, opts ...c
// FromService wraps a client to inject From-Service header into metadata
func FromService(name string, c client.Client) client.Client {
return &clientWrapper{
c,
metadata.Metadata{
HeaderPrefix + "From-Service": name,
},
}
c,
metadata.Metadata{
HeaderPrefix + "From-Service": name,
},
}
}

0 comments on commit eeed493

Please sign in to comment.