23 lines
502 B
Go
23 lines
502 B
Go
package nomino
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMake(t *testing.T) {
|
|
conf := NewConfig(WithGenerator(func() (string, error) { return "abc", nil }))
|
|
st, err := Make(conf)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "abc", st)
|
|
}
|
|
|
|
func TestMakeErr(t *testing.T) {
|
|
retErr := errors.New("oops")
|
|
conf := NewConfig(WithGenerator(func() (string, error) { return "foobar", retErr }))
|
|
st, err := Make(conf)
|
|
assert.Zero(t, st)
|
|
assert.ErrorIs(t, err, retErr)
|
|
}
|