| 1 |
// Code generated by gotmpl. DO NOT MODIFY. |
| 2 |
// source: internal/shared/otlp/partialsuccess_test.go |
| 3 |
|
| 4 |
// Copyright The OpenTelemetry Authors |
| 5 |
// SPDX-License-Identifier: Apache-2.0 |
| 6 |
|
| 7 |
package internal |
| 8 |
|
| 9 |
import ( |
| 10 |
"strings" |
| 11 |
"testing" |
| 12 |
|
| 13 |
"github.com/stretchr/testify/require" |
| 14 |
) |
| 15 |
|
| 16 |
func requireErrorString(t *testing.T, expect string, err error) { |
| 17 |
t.Helper() |
| 18 |
require.Error(t, err) |
| 19 |
require.ErrorIs(t, err, PartialSuccess{}) |
| 20 |
|
| 21 |
const pfx = "OTLP partial success: " |
| 22 |
|
| 23 |
msg := err.Error() |
| 24 |
require.True(t, strings.HasPrefix(msg, pfx)) |
| 25 |
require.Equal(t, expect, msg[len(pfx):]) |
| 26 |
} |
| 27 |
|
| 28 |
func TestPartialSuccessFormat(t *testing.T) { |
| 29 |
requireErrorString(t, "empty message (0 metric data points rejected)", MetricPartialSuccessError(0, "")) |
| 30 |
requireErrorString(t, "help help (0 metric data points rejected)", MetricPartialSuccessError(0, "help help")) |
| 31 |
requireErrorString( |
| 32 |
t, |
| 33 |
"what happened (10 metric data points rejected)", |
| 34 |
MetricPartialSuccessError(10, "what happened"), |
| 35 |
) |
| 36 |
requireErrorString(t, "what happened (15 spans rejected)", TracePartialSuccessError(15, "what happened")) |
| 37 |
} |