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
Raw Normal View History

2019-05-31 10:07:40 +02:00
package component
2019-06-01 04:38:35 +02:00
import (
"errors"
2019-06-01 04:38:35 +02:00
"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)
2019-06-01 04:38:35 +02:00
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"},
})
2019-06-01 04:38:35 +02:00
})
}