This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
thrempp/component/main_test.go

39 lines
724 B
Go

package component
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestAddComponent(t *testing.T) {
assert := assert.New(t)
AddComponent("a", func(config map[string]interface{}) (Component, error) { return nil, nil })
assert.NotNil(components["a"])
assert.Len(components, 1)
}
func TestLoad(t *testing.T) {
assert := assert.New(t)
AddComponent("error", func(config map[string]interface{}) (Component, error) {
return nil, errors.New("dummy")
})
// error on component
assert.Panics(func() {
Load([]Config{
{Type: "error", Connection: "[::1]:10001"},
})
})
// error on connect
assert.Panics(func() {
Load([]Config{
{Type: "a", Connection: "[::1]:10001"},
})
})
}