Files
Matthieu MORELandGitHub 478dd20c3d [chore]: fix testifylint rules (#12791)
#### Description

Fixes testifylint rules which where disabled with golangci-lint v2
upgrade

Signed-off-by: Matthieu MOREL <[email protected]>
2025-04-02 23:10:07 +00:00

47 lines
1.2 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package xconsumererror // import "go.opentelemetry.io/collector/consumer/consumererror/xconsumererror"
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/pdata/testdata"
)
func TestProfiles(t *testing.T) {
td := testdata.GenerateProfiles(1)
err := errors.New("some error")
profileErr := NewProfiles(err, td)
assert.Equal(t, err.Error(), profileErr.Error())
var target Profiles
assert.NotErrorAs(t, nil, &target)
assert.NotErrorAs(t, err, &target)
require.ErrorAs(t, profileErr, &target)
assert.Equal(t, td, target.Data())
}
func TestProfiles_Unwrap(t *testing.T) {
td := testdata.GenerateProfiles(1)
var err error = testErrorType{"some error"}
// Wrapping err with error Profiles.
profileErr := NewProfiles(err, td)
target := testErrorType{}
require.NotEqual(t, err, target)
// Unwrapping profileErr for err and assigning to target.
require.ErrorAs(t, profileErr, &target)
require.Equal(t, err, target)
}
type testErrorType struct {
s string
}
func (t testErrorType) Error() string {
return ""
}