Files
telemetry/scraper/scrapererror/partialscrapeerror_test.go
32abecb5cc [chore] move receiver/scrapererror to scraper/scrapererror (#11733)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Migrates existing scrapererror code to new scraper package. Sets aliases
for receiver/scrapererror so that dependent code in contrib and
elsewhere can be updated
<!-- Issue number if applicable -->
#### Link to tracking issue
Relates to #11003

<!--Describe what testing was performed and which tests were added.-->
#### Testing
included unit/integration tests should suffice
<!--Describe the documentation added.-->
#### Documentation
changelog yaml
<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Pablo Baeyens <[email protected]>
Co-authored-by: Pablo Baeyens <[email protected]>
2024-12-02 10:20:12 -08:00

29 lines
654 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package scrapererror
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPartialScrapeError(t *testing.T) {
failed := 2
err := errors.New("some error")
partialErr := NewPartialScrapeError(err, failed)
require.EqualError(t, err, partialErr.Error())
assert.Equal(t, failed, partialErr.Failed)
}
func TestIsPartialScrapeError(t *testing.T) {
err := errors.New("testError")
require.False(t, IsPartialScrapeError(err))
err = NewPartialScrapeError(err, 2)
require.True(t, IsPartialScrapeError(err))
}