Skip to content

Commit d7a8a2c

Browse files
committed
[FAB-15193] Rewrite mocks discovery
Change-Id: I29ddb8bfa79ba0523ab302f232970b3f736a4fcb Signed-off-by: rickr <cr22rc@gmail.com>
1 parent bd7e596 commit d7a8a2c

File tree

3 files changed

+67
-7
lines changed

3 files changed

+67
-7
lines changed

discovery/support/mocks/policy_manager.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

discovery/support/support.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPDX-License-Identifier: Apache-2.0
77
package support
88

99
import (
10+
"github.com/hyperledger/fabric/common/policies"
1011
"github.com/hyperledger/fabric/discovery"
1112
"github.com/hyperledger/fabric/discovery/support/acl"
1213
)
@@ -25,6 +26,12 @@ type ChannelPolicyManagerGetter interface {
2526
acl.ChannelPolicyManagerGetter
2627
}
2728

29+
//go:generate mockery -dir . -name PolicyManager -case underscore -output mocks/
30+
31+
type PolicyManager interface {
32+
policies.Manager
33+
}
34+
2835
// DiscoverySupport aggregates all the support needed for the discovery service
2936
type DiscoverySupport struct {
3037
discovery.AccessControlSupport

discovery/test/integration_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/hyperledger/fabric/common/cauthdsl"
2929
"github.com/hyperledger/fabric/common/configtx"
3030
"github.com/hyperledger/fabric/common/crypto/tlsgen"
31-
policiesmocks "github.com/hyperledger/fabric/common/mocks/policies"
3231
"github.com/hyperledger/fabric/common/policies"
3332
"github.com/hyperledger/fabric/common/util"
3433
cc "github.com/hyperledger/fabric/core/cclifecycle"
@@ -577,13 +576,10 @@ func createPolicyManagerGetter(t *testing.T, mspMgr msp.MSPManager) *mocks.Chann
577576
assert.NoError(t, err)
578577
org1Org2MembersPolicy, _, err := cauthdsl.NewPolicyProvider(mspMgr).NewPolicy(protoutil.MarshalOrPanic(org1Org2Members))
579578
assert.NoError(t, err)
580-
_ = org1Org2MembersPolicy
579+
581580
polMgr := &mocks.ChannelPolicyManagerGetter{}
582-
policyMgr := &policiesmocks.Manager{
583-
PolicyMap: map[string]policies.Policy{
584-
policies.ChannelApplicationWriters: org1Org2MembersPolicy,
585-
},
586-
}
581+
policyMgr := &mocks.PolicyManager{}
582+
policyMgr.On("GetPolicy", policies.ChannelApplicationWriters).Return(org1Org2MembersPolicy, true)
587583
polMgr.On("Manager", "mychannel").Return(policyMgr, false)
588584
return polMgr
589585
}

0 commit comments

Comments
 (0)