| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package scrapererror |
| 5 |
|
| 6 |
import ( |
| 7 |
"errors" |
| 8 |
"testing" |
| 9 |
|
| 10 |
"github.com/stretchr/testify/assert" |
| 11 |
"github.com/stretchr/testify/require" |
| 12 |
) |
| 13 |
|
| 14 |
func TestPartialScrapeError(t *testing.T) { |
| 15 |
failed := 2 |
| 16 |
err := errors.New("some error") |
| 17 |
partialErr := NewPartialScrapeError(err, failed) |
| 18 |
require.EqualError(t, err, partialErr.Error()) |
| 19 |
assert.Equal(t, failed, partialErr.Failed) |
| 20 |
} |
| 21 |
|
| 22 |
func TestIsPartialScrapeError(t *testing.T) { |
| 23 |
err := errors.New("testError") |
| 24 |
require.False(t, IsPartialScrapeError(err)) |
| 25 |
|
| 26 |
err = NewPartialScrapeError(err, 2) |
| 27 |
require.True(t, IsPartialScrapeError(err)) |
| 28 |
} |