-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_test.go
39 lines (31 loc) · 909 Bytes
/
random_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
33
34
35
36
37
38
39
package awsutils
import (
"testing"
)
func TestGeneratePasswordErrors(t *testing.T) {
empty := ""
_, err := GeneratePassword(0, 1, 1, nil, nil, nil)
if err.Error() != exceedsTotalLength {
t.Errorf("expected %q to be %q", err, exceedsTotalLength)
}
_, err = GeneratePassword(0, 1, 1, nil, &empty, nil)
if err.Error() != allowedNumbersMustBeDefined {
t.Errorf("expected %q to be %q", err, allowedNumbersMustBeDefined)
}
_, err = GeneratePassword(0, 1, 1, nil, nil, &empty)
if err.Error() != allowedSymbolsMustBeDefined {
t.Errorf("expected %q to be %q", err, allowedNumbersMustBeDefined)
}
}
func TestGeneratePassword(t *testing.T) {
letters := "abAB"
numbers := "01"
symbols := "!?"
pass, err := GeneratePassword(4, 1, 1, &letters, &numbers, &symbols)
if err != nil {
t.Errorf(err.Error())
}
if len(pass) != 4 {
t.Errorf("the password was expected to be of size four")
}
}