forked from couchbase/gocbcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kvmux_test.go
75 lines (64 loc) · 3.77 KB
/
kvmux_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package gocbcore
func (suite *StandardTestSuite) TestKvMux_HasBucketCapabilityStatusNoState() {
// No mux state, shouldn't actually happen in practise.
mux := kvMux{}
suite.Assert().True(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusUnknown))
suite.Assert().False(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusSupported))
suite.Assert().False(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusUnsupported))
suite.Assert().True(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusUnknown))
suite.Assert().False(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusSupported))
suite.Assert().False(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusUnsupported))
}
func (suite *StandardTestSuite) TestKvMux_HasBucketCapabilityStatusBlankState() {
cfg := &routeConfig{
revID: -1,
}
// Mux state as if we haven't received a config yet.
muxState := newKVMuxState(cfg, nil, nil, nil, nil, nil, nil)
mux := kvMux{}
mux.updateState(nil, muxState)
suite.Assert().True(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusUnknown))
suite.Assert().False(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusSupported))
suite.Assert().False(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusUnsupported))
suite.Assert().False(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusUnknown))
suite.Assert().False(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusSupported))
suite.Assert().True(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusUnsupported))
}
func (suite *StandardTestSuite) TestKvMux_HasBucketCapabilityStatusUnsupported() {
// Mux state as if we have received a config yet.
muxState := &kvMuxState{
routeCfg: routeConfig{
revID: 1,
},
bucketCapabilities: map[BucketCapability]BucketCapabilityStatus{
BucketCapabilityReplaceBodyWithXattr: BucketCapabilityStatusUnsupported,
},
}
mux := kvMux{}
mux.updateState(nil, muxState)
suite.Assert().False(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusUnknown))
suite.Assert().False(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusSupported))
suite.Assert().True(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusUnsupported))
suite.Assert().False(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusUnknown))
suite.Assert().False(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusSupported))
suite.Assert().True(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusUnsupported))
}
func (suite *StandardTestSuite) TestKvMux_HasBucketCapabilityStatusSupported() {
// Mux state as if we have received a config yet.
muxState := &kvMuxState{
routeCfg: routeConfig{
revID: 1,
},
bucketCapabilities: map[BucketCapability]BucketCapabilityStatus{
BucketCapabilityReplaceBodyWithXattr: BucketCapabilityStatusSupported,
},
}
mux := kvMux{}
mux.updateState(nil, muxState)
suite.Assert().False(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusUnknown))
suite.Assert().True(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusSupported))
suite.Assert().False(mux.HasBucketCapabilityStatus(BucketCapabilityReplaceBodyWithXattr, BucketCapabilityStatusUnsupported))
suite.Assert().False(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusUnknown))
suite.Assert().False(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusSupported))
suite.Assert().True(mux.HasBucketCapabilityStatus(9999, BucketCapabilityStatusUnsupported))
}