@@ -11,33 +11,40 @@ import (
1111)
1212
1313const projectResponse = `{
14- "project": {
15- "id": 643,
16- "name": "Open-Source",
17- "note": "valvat, memento et all.",
18- "customer_id": 291,
19- "customer_name": "Yolk",
20- "budget": 0,
21- "budget_type": "minutes",
22- "hourly_rate": 6000,
23- "archived": false,
24- "active_hourly_rate": "hourly_rate",
25- "hourly_rates_per_service": [
26- {
27- "service_id": 31272,
28- "hourly_rate": 4500
29- },
30- {
31- "service_id": 149228,
32- "hourly_rate": 5500
33- }
34- ],
35- "created_at": "2011-08-17T12:06:57+02:00",
36- "updated_at": "2015-02-19T10:53:10+01:00"
37- }
14+ "project": {
15+ "id": 643,
16+ "name": "Open-Source",
17+ "note": "valvat, memento et all.",
18+ "customer_id": 291,
19+ "customer_name": "Yolk",
20+ "budget": 0,
21+ "budget_type": "minutes",
22+ "hourly_rate": 6000,
23+ "archived": false,
24+ "active_hourly_rate": "hourly_rate",
25+ "hourly_rates_per_service": [
26+ {
27+ "service_id": 31272,
28+ "hourly_rate": 4500
29+ },
30+ {
31+ "service_id": 149228,
32+ "hourly_rate": 5500
33+ }
34+ ],
35+ "created_at": "2011-08-17T12:06:57+02:00",
36+ "updated_at": "2015-02-19T10:53:10+01:00"
37+ }
3838}`
3939
40+ var projectObject = domain.Project {
41+ Id : domain .NewProjectId (643 ),
42+ Name : "Open-Source" ,
43+ Note : "valvat, memento et all." ,
44+ }
45+
4046func TestApi_Projects (t * testing.T ) {
47+ // given
4148 rec := recorder {}
4249 srv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
4350 rec .method = r .Method
@@ -47,19 +54,19 @@ func TestApi_Projects(t *testing.T) {
4754
4855 w .Header ().Add ("Content-Type" , "application/json; charset=utf-8" )
4956 w .WriteHeader (200 )
50- w .Write ([]byte (fmt .Sprintf ("[%s]" , projectResponse )))
57+ _ , _ = w .Write ([]byte (fmt .Sprintf ("[%s]" , projectResponse )))
5158 }))
5259
5360 defer srv .Close ()
5461
5562 api := mite .NewApi (srv .URL , testApiKey , testClientVersion )
63+
64+ // when
5665 projects , err := api .Projects ()
5766
67+ // then
5868 assert .Nil (t , err )
59- assert .Equal (t , []* domain.Project {{
60- Id : domain .NewProjectId (643 ),
61- Name : "Open-Source" ,
62- Note : "valvat, memento et all." }}, projects )
69+ assert .Equal (t , []* domain.Project {& projectObject }, projects )
6370
6471 assert .Equal (t , http .MethodGet , rec .method )
6572 assert .Equal (t , "/projects.json" , rec .url )
0 commit comments