-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviolations_test.go
42 lines (34 loc) · 1.06 KB
/
violations_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
40
41
42
package candidate_test
import (
"fmt"
"testing"
"github.com/barolab/candidate"
)
var expectedAllViolationsString = fmt.Sprintf(
"- %s\n- %s\n- %s\n- %s\n- \n",
"NAME_TOO_LONG",
"NAME_TOO_SHORT",
"NAME_CONTAINS_ILLEGAL_PATTERNS",
"NAME_CONTAINS_ILLEGAL_CHARACTERS",
)
func TestViolations(T *testing.T) {
violations := candidate.Violations{
candidate.NameTooLong,
candidate.NameTooShort,
candidate.NameContainsIllegalPattern,
candidate.NameContainsIllegalCharacters,
11, // unkown violation
}
if violations.String() != expectedAllViolationsString {
T.Errorf("Failed to validate that all violations string match expected %s, got %s", expectedAllViolationsString, violations.String())
}
if violations.IsNil() {
T.Errorf("Failed to validate that a full violations is not nil...")
}
if violations.IsEqual(candidate.Violations{}) {
T.Errorf("Fail to validate that isEqual returns false for an empty violations and a full one")
}
if !violations.IsEqual(violations) {
T.Errorf("Failed to validate that a full violations is equal with itsel")
}
}