-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructures_rattachements_test.go
90 lines (82 loc) · 2.34 KB
/
structures_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
package choruspro
import (
"context"
"encoding/json"
"net/http"
"reflect"
"testing"
)
func TestUtilisateursService_RecupererRattachementsServicesUtilisateur(t *testing.T) {
client, mux, teardown := setup()
defer teardown()
mux.HandleFunc("/cpro/structures/v1/lister/rattachementsutilisateur", func(w http.ResponseWriter, r *http.Request) {
v := new(ListeRattachementsServicesUtilisateurOptions)
assertNilError(t, json.NewDecoder(r.Body).Decode(v))
testMethod(t, r, http.MethodPost)
w.Write([]byte(`{
"codeRetour": 1,
"libelle": "l",
"designationStructure": "d",
"idStructure": 1,
"identifiantStructure": "i",
"premierService": true,
"listeServices": [
{
"codeService": "c",
"commentaire": "c",
"dateDebut": ` + defaultISODateTimeStr + `,
"dateFin":` + defaultISODateTimeStr + `,
"idRattachement": 1,
"idService": 1,
"nomService": "n",
"statutRattachement": "s"
}
],
"parametresRetour": {
"pageCourante": 1,
"pages": 1,
"nbResultatsParPage": 1,
"total": 1
}
}`))
})
ctx := context.Background()
opt := ListeRattachementsServicesUtilisateurOptions{}
got, err := client.Structures.RecupererRattachementsServicesUtilisateur(ctx, opt)
if err != nil {
t.Errorf("Structures.RecupererRattachementsServicesUtilisateur returned error : %v", err)
}
want := &ListeRattachementsServicesUtilisateurResponse{
CodeRetour: 1,
Libelle: "l",
DesignationStructure: "d",
IdStructure: 1,
IdentifiantStructure: "i",
PremierService: true,
Rattachements: []RattachementServiceUtilisateur{
{
CodeService: "c",
Commentaire: "c",
DateDebut: &defaultDate,
DateFin: &defaultDate,
IdRattachement: 1,
IdService: 1,
NomService: "n",
StatutRattachement: "s",
},
},
Pagination: &PaginationResponse{
PageCourante: 1,
Pages: 1,
NbResultatsParPage: 1,
Total: 1,
},
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Structures.RecupererRattachementsServicesUtilisateur returned %+v, want %+v", got, want)
}
testNewRequestAndDoRequestFailure(t, "RecupererRattachementsServicesUtilisateur", client, func() error {
_, err := client.Structures.RecupererRattachementsServicesUtilisateur(ctx, opt)
return err
})
}