1 /**
2     This module implements integration tests for Influx API
3 
4     Authors: Atila Neves (Kaleidic Associates Advisory Limited)
5 
6     Generated documentation:
7         http://influxdb.code.kaleidic.io/influxdb.html
8 
9 */
10 module integration.asdf;
11 
12 import asdf;
13 import influxdb.api;
14 import unit_threaded;
15 
16 
17 ///
18 @("deserialise Response")
19 @system unittest {
20     enum jsonString = `
21         {
22             "results": [{
23                     "series": [{
24                             "columns": ["time", "othervalue", "tag1", "tag2", "value"],
25                             "name": "myname",
26                             "values": [
27                                     ["2015-06-11T20:46:02Z", 4, "toto", "titi", 2],
28                                     ["2017-03-14T23:15:01.06282785Z", 3, "letag", "othertag", 1]
29                             ]
30                     }],
31                     "statement_id": 42
32             }]
33         }
34         `;
35 
36     jsonString.deserialize!Response.shouldEqual(
37         Response(
38             [
39                 Result(
40                     [
41                         MeasurementSeries(
42                             "myname", //name
43                             ["time", "othervalue", "tag1", "tag2", "value"], //columns
44                             //values
45                             [
46                                 ["2015-06-11T20:46:02Z", "4", "toto", "titi", "2"],
47                                 ["2017-03-14T23:15:01.06282785Z", "3", "letag", "othertag", "1"],
48                             ]
49                         ),
50                     ],
51 
52                     42, // statement_id
53                 )
54             ]
55         )
56     );
57 }
58 
59 
60 /**
61     Example:
62 */
63 void shouldBeSameJsonAs(in string actual,
64                         in string expected,
65                         in string file = __FILE__,
66                         in size_t line = __LINE__)
67     @trusted // parseJSON
68 {
69     import std.json;
70     actual.parseJSON.toPrettyString.shouldEqual(expected.parseJSON.toPrettyString, file, line);
71 }