@@ -6,15 +6,15 @@ extern crate rocket;
6
6
extern crate aw_datastore;
7
7
extern crate aw_server;
8
8
9
- // TODO: Validate return data on more places
10
-
11
9
#[ cfg( test) ]
12
10
mod api_tests {
13
- use chrono:: { DateTime , Utc } ;
14
- use rocket:: http:: { ContentType , Header , Status } ;
11
+ use std:: collections:: HashMap ;
15
12
use std:: path:: PathBuf ;
16
13
use std:: sync:: Mutex ;
17
14
15
+ use chrono:: { DateTime , Utc } ;
16
+ use rocket:: http:: { ContentType , Header , Status } ;
17
+
18
18
use aw_server:: config;
19
19
use aw_server:: endpoints;
20
20
@@ -44,6 +44,9 @@ mod api_tests {
44
44
. dispatch ( ) ;
45
45
debug ! ( "{:?}" , res. body_string( ) ) ;
46
46
assert_eq ! ( res. status( ) , rocket:: http:: Status :: Ok ) ;
47
+ let buckets: HashMap < String , Bucket > =
48
+ serde_json:: from_str ( & res. body_string ( ) . unwrap ( ) ) . unwrap ( ) ;
49
+ assert_eq ! ( buckets. len( ) , 0 ) ;
47
50
48
51
// Try to fetch non-existing bucket
49
52
res = client
@@ -91,8 +94,18 @@ mod api_tests {
91
94
. header ( ContentType :: JSON )
92
95
. dispatch ( ) ;
93
96
debug ! ( "{:?}" , res. body_string( ) ) ;
94
- // TODO: assert data
95
97
assert_eq ! ( res. status( ) , rocket:: http:: Status :: Ok ) ;
98
+ let buckets: HashMap < String , Bucket > =
99
+ serde_json:: from_str ( & res. body_string ( ) . unwrap ( ) ) . unwrap ( ) ;
100
+ assert_eq ! ( buckets. len( ) , 1 ) ;
101
+ let bucket = buckets. get ( "id" ) . unwrap ( ) ;
102
+ assert_eq ! ( bucket. id, "id" ) ;
103
+ assert_eq ! ( bucket. _type, "type" ) ;
104
+ assert_eq ! ( bucket. client, "client" ) ;
105
+ assert_eq ! ( bucket. hostname, "hostname" ) ;
106
+ assert_eq ! ( bucket. events, None ) ;
107
+ assert_eq ! ( bucket. metadata. start, None ) ;
108
+ assert_eq ! ( bucket. metadata. end, None ) ;
96
109
97
110
// Get newly created bucket
98
111
res = client
@@ -134,6 +147,17 @@ mod api_tests {
134
147
. dispatch ( ) ;
135
148
debug ! ( "{:?}" , res. body_string( ) ) ;
136
149
assert_eq ! ( res. status( ) , rocket:: http:: Status :: NotFound ) ;
150
+
151
+ // Get empty list of buckets
152
+ let mut res = client
153
+ . get ( "/api/0/buckets/" )
154
+ . header ( ContentType :: JSON )
155
+ . dispatch ( ) ;
156
+ debug ! ( "{:?}" , res. body_string( ) ) ;
157
+ assert_eq ! ( res. status( ) , rocket:: http:: Status :: Ok ) ;
158
+ let buckets: HashMap < String , Bucket > =
159
+ serde_json:: from_str ( & res. body_string ( ) . unwrap ( ) ) . unwrap ( ) ;
160
+ assert_eq ! ( buckets. len( ) , 0 ) ;
137
161
}
138
162
139
163
#[ test]
0 commit comments