✨ Add Make function
This is the important one
This commit is contained in:
parent
7bd5503613
commit
7126ef97a4
2 changed files with 38 additions and 0 deletions
23
make_test.go
Normal file
23
make_test.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue