File tree 2 files changed +7
-27
lines changed
2 files changed +7
-27
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ def parse!
48
48
parse_single ( @message , ERROR )
49
49
parse_single ( @message , ERRMSG )
50
50
parse_multiple ( @message , WRITE_ERRORS )
51
- parse_multiple ( @message , WRITE_CONCERN_ERROR )
51
+ parse_single ( @message , ERRMSG ,
52
+ document [ WRITE_CONCERN_ERROR ] ) if document [ WRITE_CONCERN_ERROR ]
52
53
end
53
54
54
55
def parse_single ( message , key , doc = document )
Original file line number Diff line number Diff line change 84
84
end
85
85
end
86
86
87
- context 'when the document contains writeConcernErrors ' do
87
+ context 'when the document contains a writeConcernError ' do
88
88
89
- context 'when a single error exists' do
90
-
91
- let ( :document ) do
92
- { 'writeConcernError' => [ { 'errmsg' => 'not authorized for query' , 'code' => 13 } ] }
93
- end
94
-
95
- it 'returns the message' do
96
- expect ( parser . message ) . to eq ( 'not authorized for query (13)' )
97
- end
89
+ let ( :document ) do
90
+ { 'writeConcernError' => { 'code' => 100 , 'errmsg' => 'Not enough data-bearing nodes' } }
98
91
end
99
92
100
- context 'when multiple errors exist' do
101
-
102
- let ( :document ) do
103
- {
104
- 'writeConcernError' => [
105
- { 'code' => 9 , 'errmsg' => 'Unknown modifier: $st' } ,
106
- { 'code' => 9 , 'errmsg' => 'Unknown modifier: $bl' }
107
- ]
108
- }
109
- end
110
-
111
- it 'returns the messages concatenated' do
112
- expect ( parser . message ) . to eq (
113
- 'Unknown modifier: $st (9), Unknown modifier: $bl (9)'
114
- )
115
- end
93
+ it 'returns the message' do
94
+ expect ( parser . message ) . to eq ( 'Not enough data-bearing nodes (100)' )
116
95
end
117
96
end
118
97
end
You can’t perform that action at this time.
0 commit comments