issue_294 #301

Merged
vtolstov merged 6 commits from devstigneev/micro:issue_294 into master 2024-02-29 23:37:52 +03:00
2 changed files with 36 additions and 1 deletions
Showing only changes of commit e212e3dc50 - Show all commits

View File

@ -3,7 +3,9 @@ package memory
import ( import (
"context" "context"
"fmt" "fmt"
"go.unistack.org/micro/v4"
"go.unistack.org/micro/v4/register" "go.unistack.org/micro/v4/register"
"reflect"
"sync" "sync"
"testing" "testing"
"time" "time"
@ -321,3 +323,36 @@ func TestWatcher(t *testing.T) {
t.Fatal("expected error on Next()") t.Fatal("expected error on Next()")
} }
} }
func Test_service_Register(t *testing.T) {
r := NewRegister()
type args struct {
names []string
}
tests := []struct {
name string
opts []micro.Option
args args
want register.Register
}{
{
name: "service.Register",
opts: []micro.Option{micro.Register(r)},
args: args{
names: []string{"memory"},
},
want: r,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := micro.NewService(tt.opts...)
Review

если так использовать Мемори не прокинется

если так использовать Мемори не прокинется
if got := s.Register(tt.args.names...); !reflect.DeepEqual(got, tt.want) {
t.Errorf("service.Register() = %v, want %v", got, tt.want)
}
})
}
}

View File

@ -445,7 +445,7 @@ func Test_service_Register(t *testing.T) {
opts: Options{Registers: []register.Register{r}}, opts: Options{Registers: []register.Register{r}},
}, },
args: args{ args: args{
names: []string{"noop"}, names: []string{"memory"},
}, },
want: r, want: r,
}, },