1
1
#![ allow( dead_code) ]
2
2
3
+ extern crate itertools;
4
+
3
5
extern crate futures;
4
6
extern crate reqwest;
5
7
extern crate tokio;
6
8
7
9
use futures:: Future ;
8
- use reqwest:: r#async:: Client ;
9
10
11
+ use itertools:: Itertools ;
12
+ use reqwest:: r#async:: Client ;
10
13
trait InfluxDbQuery {
11
14
fn build < ' a > ( self ) -> String ;
12
15
}
@@ -55,13 +58,11 @@ impl InfluxDbQuery for InfluxDbWrite {
55
58
. tags
56
59
. into_iter ( )
57
60
. map ( |( tag, value) | format ! ( "{tag}={value}" , tag = tag, value = value) )
58
- . collect :: < Vec < String > > ( )
59
61
. join ( "," ) ;
60
62
let fields = self
61
63
. fields
62
64
. into_iter ( )
63
65
. map ( |( field, value) | format ! ( "{field}={value}" , field = field, value = value) )
64
- . collect :: < Vec < String > > ( )
65
66
. join ( "," ) ;
66
67
67
68
format ! (
@@ -136,9 +137,8 @@ mod tests {
136
137
137
138
#[ test]
138
139
fn test_write_builder_single_field ( ) {
139
- let query = InfluxDbQuery :: write ( )
140
- . add_field ( "water_level" , "2" ) ;
141
-
140
+ let query = InfluxDbQuery :: write ( ) . add_field ( "water_level" , "2" ) ;
141
+
142
142
assert_eq ! ( query. build( ) , "measurement, water_level=2 time" ) ;
143
143
}
144
144
@@ -159,8 +159,7 @@ mod tests {
159
159
// fixme: quoting / escaping of long strings
160
160
#[ test]
161
161
fn test_write_builder_single_tag ( ) {
162
- let query = InfluxDbQuery :: write ( )
163
- . add_tag ( "marina_manager" , "Smith" ) ;
162
+ let query = InfluxDbQuery :: write ( ) . add_tag ( "marina_manager" , "Smith" ) ;
164
163
165
164
assert_eq ! ( query. build( ) , "measurement,marina_manager=Smith time" ) ;
166
165
}
@@ -194,6 +193,9 @@ mod tests {
194
193
195
194
#[ test]
196
195
fn test_test ( ) {
197
- InfluxDbQuery :: write ( ) . add_field ( "test" , "1" ) . add_tag ( "my_tag" , "0.85" ) . build ( ) ;
196
+ InfluxDbQuery :: write ( )
197
+ . add_field ( "test" , "1" )
198
+ . add_tag ( "my_tag" , "0.85" )
199
+ . build ( ) ;
198
200
}
199
201
}
0 commit comments