-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy patherror_query_test.go
30 lines (26 loc) · 1.06 KB
/
error_query_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
package gocb
import "encoding/json"
func (suite *UnitTestSuite) TestQueryError() {
aErr := QueryError{
InnerError: ErrIndexFailure,
Statement: "select * from dataset",
ClientContextID: "12345",
Errors: []QueryErrorDesc{{
Code: 1000,
Message: "error 1000",
}},
Endpoint: "http://127.0.0.1:8093",
RetryReasons: []RetryReason{QueryIndexNotFoundRetryReason},
RetryAttempts: 3,
}
b, err := json.Marshal(aErr)
suite.Require().Nil(err)
suite.Assert().Equal(
[]byte("{\"msg\":\"index failure\",\"statement\":\"select * from dataset\",\"client_context_id\":\"12345\",\"errors\":[{\"Code\":1000,\"Message\":\"error 1000\"}],\"endpoint\":\"http://127.0.0.1:8093\",\"retry_reasons\":[\"QUERY_INDEX_NOT_FOUND\"],\"retry_attempts\":3}"),
b,
)
suite.Assert().Equal(
"index failure | {\"statement\":\"select * from dataset\",\"client_context_id\":\"12345\",\"errors\":[{\"Code\":1000,\"Message\":\"error 1000\"}],\"endpoint\":\"http://127.0.0.1:8093\",\"retry_reasons\":[\"QUERY_INDEX_NOT_FOUND\"],\"retry_attempts\":3}",
aErr.Error(),
)
}