go around circuit breaker

This commit is contained in:
A.Unger committed 2021-02-23 14:25:16 +01:00
1 parent 9a507a4450
commit 9342b5abbd
1 file changed
+29 -27
+29 -27
View File
@@ -10,6 +10,8 @@ import (
"path/filepath"
"testing"
mgrpcc "github.com/asim/go-micro/plugins/client/grpc/v3"
"github.com/asim/go-micro/v3/client"
merrors "github.com/asim/go-micro/v3/errors"
"github.com/golang/protobuf/ptypes/empty"
@@ -24,7 +26,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)
var service = grpc.Service{}
var service = grpc.NewService()
var dataPath = createTmpDir()
@@ -313,7 +315,7 @@ func assertGroupHasMember(t *testing.T, grp *proto.Group, memberId string) {
}
func createAccount(t *testing.T, user string) (*proto.Account, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
account := getAccount(user)
@@ -326,7 +328,7 @@ func createAccount(t *testing.T, user string) (*proto.Account, error) {
}
func createGroup(t *testing.T, group *proto.Group) (*proto.Group, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
request := &proto.CreateGroupRequest{Group: group}
@@ -338,7 +340,7 @@ func createGroup(t *testing.T, group *proto.Group) (*proto.Group, error) {
}
func updateAccount(t *testing.T, account *proto.Account, updateArray []string) (*proto.Account, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
updateMask := &field_mask.FieldMask{
@@ -352,7 +354,7 @@ func updateAccount(t *testing.T, account *proto.Account, updateArray []string) (
func listAccounts(t *testing.T) (*proto.ListAccountsResponse, error) {
request := &proto.ListAccountsRequest{}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
response, err := cl.ListAccounts(context.Background(), request)
@@ -361,7 +363,7 @@ func listAccounts(t *testing.T) (*proto.ListAccountsResponse, error) {
func listGroups(t *testing.T) *proto.ListGroupsResponse {
request := &proto.ListGroupsRequest{}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
response, err := cl.ListGroups(context.Background(), request)
@@ -370,7 +372,7 @@ func listGroups(t *testing.T) *proto.ListGroupsResponse {
}
func deleteAccount(t *testing.T, id string) (*empty.Empty, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
req := &proto.DeleteAccountRequest{Id: id}
@@ -379,7 +381,7 @@ func deleteAccount(t *testing.T, id string) (*empty.Empty, error) {
}
func deleteGroup(t *testing.T, id string) (*empty.Empty, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.DeleteGroupRequest{Id: id}
@@ -767,7 +769,7 @@ func TestDeleteAccount(t *testing.T) {
req := &proto.DeleteAccountRequest{Id: getAccount("user1").Id}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewAccountsService("com.owncloud.api.accounts", client)
resp, err := cl.DeleteAccount(context.Background(), req)
@@ -785,7 +787,7 @@ func TestDeleteAccount(t *testing.T) {
func TestListGroups(t *testing.T) {
req := &proto.ListGroupsRequest{}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
resp, err := cl.ListGroups(context.Background(), req)
@@ -812,7 +814,7 @@ func TestListGroups(t *testing.T) {
}
func TestGetGroups(t *testing.T) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
groups := []string{
@@ -860,7 +862,7 @@ func TestCreateGroup(t *testing.T) {
}
func TestGetGroupInvalidID(t *testing.T) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.GetGroupRequest{Id: "42"}
@@ -880,7 +882,7 @@ func TestDeleteGroup(t *testing.T) {
createGroup(t, grp2)
createGroup(t, grp3)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.DeleteGroupRequest{Id: grp1.Id}
@@ -909,7 +911,7 @@ func TestDeleteGroupNotExisting(t *testing.T) {
" ",
}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
for _, id := range invalidIds {
@@ -932,7 +934,7 @@ func TestDeleteGroupInvalidId(t *testing.T) {
"": ".",
}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
for id := range invalidIds {
@@ -949,7 +951,7 @@ func TestUpdateGroup(t *testing.T) {
grp1 := getTestGroups("grp1")
createGroup(t, grp1)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
updateGrp := &proto.Group{
@@ -978,7 +980,7 @@ func TestAddMember(t *testing.T) {
createGroup(t, grp1)
createAccount(t, account.PreferredName)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.AddMemberRequest{GroupId: grp1.Id, AccountId: account.Id}
@@ -1010,7 +1012,7 @@ func TestAddMemberAlreadyInGroup(t *testing.T) {
addMemberToGroup(t, grp1.Id, account.Id)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.AddMemberRequest{GroupId: grp1.Id, AccountId: account.Id}
@@ -1035,7 +1037,7 @@ func TestAddMemberNonExisting(t *testing.T) {
createGroup(t, grp1)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
invalidIds := []string{
@@ -1063,7 +1065,7 @@ func TestAddMemberNonExisting(t *testing.T) {
}
func addMemberToGroup(t *testing.T, groupId, memberId string) (*proto.Group, error) {
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.AddMemberRequest{GroupId: groupId, AccountId: memberId}
@@ -1083,7 +1085,7 @@ func TestRemoveMember(t *testing.T) {
addMemberToGroup(t, grp1.Id, account.Id)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.RemoveMemberRequest{GroupId: grp1.Id, AccountId: account.Id}
@@ -1106,7 +1108,7 @@ func TestRemoveMemberNonExistingUser(t *testing.T) {
createGroup(t, grp1)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
invalidIds := []string{
@@ -1140,7 +1142,7 @@ func TestRemoveMemberNotInGroup(t *testing.T) {
createGroup(t, grp1)
createAccount(t, account.PreferredName)
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
req := &proto.RemoveMemberRequest{GroupId: grp1.Id, AccountId: account.Id}
@@ -1177,7 +1179,7 @@ func TestListMembers(t *testing.T) {
"physics-lovers",
}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
for _, group := range groups {
@@ -1209,7 +1211,7 @@ func TestListMembers(t *testing.T) {
func TestListMembersEmptyGroup(t *testing.T) {
group := &proto.Group{Id: "5d58e5ec-842e-498b-8800-61f2ec6f911c", GidNumber: 60000, OnPremisesSamAccountName: "quantum-group", DisplayName: "Quantum Group", Members: []*proto.Account{}}
client := service.Client()
client := mgrpcc.NewClient()
cl := proto.NewGroupsService("com.owncloud.api.accounts", client)
request := &proto.CreateGroupRequest{Group: group}
@@ -1231,7 +1233,7 @@ func TestListMembersEmptyGroup(t *testing.T) {
func TestAccountUpdateMask(t *testing.T) {
createAccount(t, "user1")
user1 := getAccount("user1")
client := service.Client()
client := mgrpcc.NewClient()
req := &proto.UpdateAccountRequest{
// We only want to update the display-name, rest should be ignored
UpdateMask: &field_mask.FieldMask{Paths: []string{"DisplayName"}},
@@ -1254,7 +1256,7 @@ func TestAccountUpdateMask(t *testing.T) {
func TestAccountUpdateReadOnlyField(t *testing.T) {
createAccount(t, "user1")
user1 := getAccount("user1")
client := service.Client()
client := mgrpcc.NewClient()
req := &proto.UpdateAccountRequest{
// We only want to update the display-name, rest should be ignored
UpdateMask: &field_mask.FieldMask{Paths: []string{"CreatedDateTime"}},