-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser_test.go
52 lines (44 loc) · 1.35 KB
/
user_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
43
44
45
46
47
48
49
50
51
52
package main
import (
"sort"
"testing"
"github.com/stretchr/testify/assert"
)
func TestUser_roles_with_niveau_a(t *testing.T) {
ass := assert.New(t)
user := User{niveau: "a"}
actual := user.getRoles()
sort.Strings(actual)
expected := []string{"score", "detection", "pge", "urssaf", "dgefp", "bdf"}
sort.Strings(expected)
ass.ElementsMatch(actual, expected)
}
func TestUser_roles_with_niveau_b(t *testing.T) {
ass := assert.New(t)
user := User{niveau: "b"}
actual := user.getRoles()
expected := []string{"score", "detection", "pge", "dgefp"}
ass.ElementsMatch(actual, expected)
}
func TestUser_roles_with_scopes(t *testing.T) {
ass := assert.New(t)
scopes := []string{"first", "second"}
user := User{niveau: "0", scope: scopes}
actual := user.getRoles()
ass.Contains(actual, scopes[0])
ass.Contains(actual, scopes[1])
}
func TestUser_roles_with_acces_geographique_and_niveau_a(t *testing.T) {
ass := assert.New(t)
accessGeographique := "any where"
user := User{niveau: "A", accesGeographique: accessGeographique}
actual := user.getRoles()
ass.Contains(actual, accessGeographique)
}
func TestUser_roles_with_acces_geographique_and_niveau_0(t *testing.T) {
ass := assert.New(t)
accessGeographique := "any where"
user := User{niveau: "0", accesGeographique: accessGeographique}
actual := user.getRoles()
ass.NotContains(actual, accessGeographique)
}