-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilisateurs_rattachements_test.go
109 lines (100 loc) · 2.9 KB
/
utilisateurs_rattachements_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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package choruspro
import (
"context"
"encoding/json"
"net/http"
"reflect"
"testing"
)
func TestUtilisateursService_RecupererRattachementsUtilisateur(t *testing.T) {
client, mux, teardown := setup()
defer teardown()
mux.HandleFunc("/cpro/utilisateurs/v1/monCompte/recuperer/rattachements", func(w http.ResponseWriter, r *http.Request) {
v := new(ListeRattachementsUtilisateurOptions)
assertNilError(t, json.NewDecoder(r.Body).Decode(v))
testMethod(t, r, http.MethodPost)
w.Write([]byte(`{
"codeRetour": 1,
"libelle": "l",
"listeStructureRattachement": [
{
"designationStructure": "s",
"idRattachementStructure": 1,
"idStructure": 1,
"identifiantStructure": "i",
"listeServicesRattache": [
{
"codeService": "s",
"dateDbtService": ` + defaultDateTimeStr + `,
"dateFinService": ` + defaultDateTimeStr + `,
"estActif": true,
"idRattachementService": 1,
"idService": 1,
"libelleService": "l",
"statutRattachementService": "a",
"statutService": "e"
}
],
"roleUtilisateur": "u",
"statutRattachementStructure": "a",
"statutUtilisateur": "a",
"typeIdentifiantStructure": "t"
}
],
"parametresRetour": {
"pageCourante": 1,
"pages": 1,
"nbResultatsParPage": 1,
"total": 1
}
}`))
})
ctx := context.Background()
opt := ListeRattachementsUtilisateurOptions{}
got, err := client.Utilisateurs.RecupererRattachementsUtilisateur(ctx, opt)
if err != nil {
t.Errorf("Utilisateurs.RecupererRattachementsUtilisateur returned error : %v", err)
}
want := &ListeRattachementsUtilisateurResponse{
CodeRetour: 1,
Libelle: "l",
Rattachements: []RattachementStructure{
{
DesignationStructure: "s",
IdRattachementStructure: 1,
IdStructure: 1,
IdentifiantStructure: "i",
ServicesRattaches: []RattachementService{
{
CodeService: "s",
DateDbtService: &Datetime{defaultDate},
DateFinService: &Datetime{defaultDate},
EstActif: true,
IdRattachementService: 1,
IdService: 1,
LibelleService: "l",
StatutRattachementService: "a",
StatutService: "e",
},
},
RoleUtilisateur: "u",
StatutRattachementStructure: "a",
StatutUtilisateur: "a",
TypeIdentifiantStructure: "t",
},
},
Pagination: &PaginationResponse{
PageCourante: 1,
Pages: 1,
NbResultatsParPage: 1,
Total: 1,
},
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Utilisateurs.RecupererRattachementsUtilisateur returned %+v, want %+v", got, want)
}
testNewRequestAndDoRequestFailure(t, "RecupererRattachementsUtilisateur", client, func() error {
_, err := client.Utilisateurs.RecupererRattachementsUtilisateur(ctx, opt)
return err
})
}