...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package internal
19
20 import (
21 "errors"
22 "strings"
23 "testing"
24
25 "github.com/stretchr/testify/require"
26 )
27
28 func requireErrorString(t *testing.T, expect string, err error) {
29 t.Helper()
30 require.NotNil(t, err)
31 require.Error(t, err)
32 require.True(t, errors.Is(err, PartialSuccess{}))
33
34 const pfx = "OTLP partial success: "
35
36 msg := err.Error()
37 require.True(t, strings.HasPrefix(msg, pfx))
38 require.Equal(t, expect, msg[len(pfx):])
39 }
40
41 func TestPartialSuccessFormat(t *testing.T) {
42 requireErrorString(t, "empty message (0 metric data points rejected)", MetricPartialSuccessError(0, ""))
43 requireErrorString(t, "help help (0 metric data points rejected)", MetricPartialSuccessError(0, "help help"))
44 requireErrorString(t, "what happened (10 metric data points rejected)", MetricPartialSuccessError(10, "what happened"))
45 requireErrorString(t, "what happened (15 spans rejected)", TracePartialSuccessError(15, "what happened"))
46 }
47
View as plain text