@@ -82,38 +82,37 @@ func newMockHARemovableNodeBackend(isRemoved func(context.Context, string) (bool
82
82
// when the context contains a removed node ID
83
83
func Test_haMembershipServerCheck (t * testing.T ) {
84
84
nodeIDCtx := metadata .NewIncomingContext (context .Background (), metadata.MD {haNodeIDKey : {"node_id" }})
85
+ otherErr := errors .New ("error checking" )
85
86
testCases := []struct {
86
87
name string
87
88
nodeIDCtx context.Context
88
89
haBackend physical.RemovableNodeHABackend
89
- wantError bool
90
+ wantError error
90
91
}{
91
92
{
92
93
name : "nil backend" ,
93
94
haBackend : nil ,
94
95
nodeIDCtx : nodeIDCtx ,
95
- wantError : false ,
96
96
}, {
97
97
name : "no node ID context" ,
98
98
haBackend : newMockHARemovableNodeBackend (func (ctx context.Context , s string ) (bool , error ) {
99
99
return false , nil
100
100
}),
101
101
nodeIDCtx : context .Background (),
102
- wantError : false ,
103
102
}, {
104
103
name : "node removed" ,
105
104
haBackend : newMockHARemovableNodeBackend (func (ctx context.Context , s string ) (bool , error ) {
106
105
return true , nil
107
106
}),
108
107
nodeIDCtx : nodeIDCtx ,
109
- wantError : true ,
108
+ wantError : StatusNotHAMember ,
110
109
}, {
111
110
name : "node removed err" ,
112
111
haBackend : newMockHARemovableNodeBackend (func (ctx context.Context , s string ) (bool , error ) {
113
- return false , errors . New ( "error checking" )
112
+ return false , otherErr
114
113
}),
115
114
nodeIDCtx : nodeIDCtx ,
116
- wantError : false ,
115
+ wantError : otherErr ,
117
116
},
118
117
}
119
118
for _ , tc := range testCases {
@@ -122,8 +121,8 @@ func Test_haMembershipServerCheck(t *testing.T) {
122
121
logger : hclog .NewNullLogger (),
123
122
}
124
123
err := haMembershipServerCheck (tc .nodeIDCtx , c , tc .haBackend )
125
- if tc .wantError {
126
- require .Error (t , err )
124
+ if tc .wantError != nil {
125
+ require .EqualError (t , err , tc . wantError . Error () )
127
126
} else {
128
127
require .NoError (t , err )
129
128
}
0 commit comments