Skip to content

Commit

Permalink
Add tests to componenttest to make codecov happy (open-telemetry#1231)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored and wyTrivail committed Jul 13, 2020
1 parent 677c522 commit 1d82920
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
12 changes: 12 additions & 0 deletions component/componenttest/error_waiting_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
)

func TestNewErrorWaitingHost(t *testing.T) {
Expand All @@ -36,3 +39,12 @@ func TestNewErrorWaitingHost(t *testing.T) {
receivedError, _ = mh.WaitForFatalError(100 * time.Millisecond)
require.False(t, receivedError)
}

func TestNewErrorWaitingHost_Noop(t *testing.T) {
mh := NewErrorWaitingHost()
require.NotNil(t, mh)

assert.Nil(t, mh.GetExporters())
assert.Nil(t, mh.GetExtensions())
assert.Nil(t, mh.GetFactory(component.KindReceiver, "test"))
}
13 changes: 10 additions & 3 deletions component/componenttest/nop_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ import (
"errors"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
)

func TestNewNopHost(t *testing.T) {
got := NewNopHost()
require.IsType(t, &NopHost{}, got)
nh := NewNopHost()
require.NotNil(t, nh)
require.IsType(t, &NopHost{}, nh)

got.ReportFatalError(errors.New("TestError"))
nh.ReportFatalError(errors.New("TestError"))
assert.Nil(t, nh.GetExporters())
assert.Nil(t, nh.GetExtensions())
assert.Nil(t, nh.GetFactory(component.KindReceiver, "test"))
}

0 comments on commit 1d82920

Please sign in to comment.