-
Notifications
You must be signed in to change notification settings - Fork 0
/
genpass_test.go
32 lines (26 loc) · 934 Bytes
/
genpass_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package genpass
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfigCalled(t *testing.T) {
var called = false
newGenerator(func(generator *generator) {
called = true
})
assert.True(t, called)
}
func TestConfigurationSet(t *testing.T) {
t.Run(`test WithCharacters changes characterType state`, func(t *testing.T) {
assert.Equal(t, newGenerator(WithCharacters(Alphabetic)).CharacterType, Alphabetic)
assert.Equal(t, newGenerator(WithCharacters(Alphanumeric)).CharacterType, Alphanumeric)
assert.Equal(t, newGenerator(WithCharacters(Numeric)).CharacterType, Numeric)
})
t.Run(`test WithLength changes length state`, func(t *testing.T) {
assert.Equal(t, newGenerator(WithLength(5)).Length, 5)
assert.Equal(t, newGenerator(WithLength(10)).Length, 10)
})
t.Run(`test WithLength handles negative numbers`, func(t *testing.T) {
assert.Equal(t, newGenerator(WithLength(-5)).Length, 0)
})
}