-
Notifications
You must be signed in to change notification settings - Fork 104
/
error_analytics_test.go
32 lines (28 loc) · 1.11 KB
/
error_analytics_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
package gocb
import (
"encoding/json"
)
func (suite *UnitTestSuite) TestAnalyticsError() {
aErr := &AnalyticsError{
InnerError: ErrDatasetNotFound,
Statement: "select * from dataset",
ClientContextID: "12345",
Errors: []AnalyticsErrorDesc{{
Code: 1000,
Message: "error 1000",
}},
Endpoint: "http://127.0.0.1:8095",
RetryReasons: []RetryReason{AnalyticsTemporaryFailureRetryReason},
RetryAttempts: 3,
}
b, err := json.Marshal(aErr)
suite.Require().Nil(err)
suite.Assert().Equal(
[]byte("{\"msg\":\"dataset not found\",\"statement\":\"select * from dataset\",\"client_context_id\":\"12345\",\"errors\":[{\"Code\":1000,\"Message\":\"error 1000\"}],\"endpoint\":\"http://127.0.0.1:8095\",\"retry_reasons\":[\"ANALYTICS_TEMPORARY_FAILURE\"],\"retry_attempts\":3}"),
b,
)
suite.Assert().Equal(
"dataset not found | {\"statement\":\"select * from dataset\",\"client_context_id\":\"12345\",\"errors\":[{\"Code\":1000,\"Message\":\"error 1000\"}],\"endpoint\":\"http://127.0.0.1:8095\",\"retry_reasons\":[\"ANALYTICS_TEMPORARY_FAILURE\"],\"retry_attempts\":3}",
aErr.Error(),
)
}