forked from mitipi/serverless-iot-offline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testData.js
89 lines (89 loc) · 2.87 KB
/
testData.js
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
module.exports.sqlParseTestData = [
{
sql: `SELECT topic(3) as deviceId, * FROM '$aws/things/sn:123/shadow/update' WHERE NOT state.reported.client.confirmed`,
payload: `{"state": {"reported": {"client": {"confirmed": false}}}}`,
expected: {
parsed: {
select: [{alias: 'deviceId', field: 'topic(3)'}, {field: '*'}],
topic: '$aws/things/sn:123/shadow/update',
whereClause: 'NOT state.reported.client.confirmed'
},
whereEvaluatesTo: true,
event: {
deviceId: 'sn:123',
state: {reported: {client: {confirmed: false}}}
}
}
},
{
sql: `SELECT state.reported.preferences.*, state.reported.activity as activityId FROM '$aws/things/+/shadow/update/accepted' WHERE state.reported.preferences.volume > 30`,
payload: `{"state": {"reported": {"preferences": {"volume": 31}, "activity": 1}}}`,
expected: {
parsed: {
select: [{field: 'state.reported.preferences.*'}, {field: 'state.reported.activity', alias: 'activityId'}],
topic: '$aws/things/+/shadow/update/accepted',
whereClause: 'state.reported.preferences.volume > 30'
},
whereEvaluatesTo: true,
event: {
volume: 31,
activityId: 1
}
}
},
{
sql: `SELECT state.desired.client FROM '$aws/things/+/shadow/update/accepted' WHERE state.desired.client = TRUE`,
payload: `{"state": {"desired": {"client": true}}}`,
expected: {
parsed: {
select: [{field: 'state.desired.client'}],
topic: '$aws/things/+/shadow/update/accepted',
whereClause: 'state.desired.client = TRUE'
},
whereEvaluatesTo: true,
event: {
client: true
}
}
},
{
sql: `SELECT *, topic(), topic(2), topic(3), topic(4) FROM '$aws/things/+/shadow/update' WHERE state.reported.mode = 'STAND_BY'`,
payload: `{"state": {"reported": {"mode": "STAND_BY"}}}`,
expected: {
parsed: {
select: [
{field: '*'},
{field: 'topic()'},
{field: 'topic(2)'},
{field: 'topic(3)'},
{field: 'topic(4)'}
],
topic: '$aws/things/+/shadow/update',
whereClause: `state.reported.mode = 'STAND_BY'`
},
whereEvaluatesTo: true,
event: {
state: {reported: {mode: 'STAND_BY'}},
topic: '$aws/things/+/shadow/update',
'topic(2)': 'things',
'topic(3)': '+',
'topic(4)': 'shadow'
}
}
},
{
sql: `SELECT clientid(), accountid() as account FROM '$aws/events/presence/connected/test_client'`,
payload: `{"event": "connected"}`,
expected: {
parsed: {
select: [{field: 'clientid()'}, {field: 'accountid()', alias: 'account'}],
topic: '$aws/events/presence/connected/test_client'
},
whereEvaluatesTo: true,
event: {
account: 'test_account',
clientid: 'test_client'
}
}
}
]