-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.lua
125 lines (97 loc) · 2.97 KB
/
main.lua
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
firebase = require('corona_firebase')
local lfs = require "lfs"
local db = firebase('https://corona.firebaseio.com/')
print("---- Begin tests ----")
print("==STREAMED GET==")
db:on("users", nil, function( data )
print("Got data!")
print(data)
end)
print("GET")
db:get("users", '?shallow=true', function(event)
if ( event.isError ) then
print( "Network error!" )
else
print ( "GET RESPONSE: " .. event.response )
end
end)
print("PUT")
db:put("users", '{"name": "Vova"}', nil, function(event)
if ( event.isError ) then
print( "Network error!" )
elseif ( event.phase == "began" ) then
print( "PUT started" )
print ( "PUT RESPONSE: " .. event.response )
elseif ( event.phase == "progress" ) then
print( "PUT in progress" )
print ( "PUT RESPONSE: " .. event.response )
elseif ( event.phase == "ended" ) then
print( "PUT ended" )
print ( "PUT RESPONSE: " .. event.response )
end
end)
print("PATCH")
db:put("users/id", '"1"', nil, function(event)
if ( event.isError ) then
print( "Network error!" )
elseif ( event.phase == "began" ) then
print( "PATCH started" )
print ( "PATCH RESPONSE: " .. event.response )
elseif ( event.phase == "progress" ) then
print( "PATCH in progress" )
print ( "PATCH RESPONSE: " .. event.response )
elseif ( event.phase == "ended" ) then
print( "PATCH ended" )
print ( "PATCH RESPONSE: " .. event.response )
end
end)
print("POST")
db:put("users/test", '[2, 3]', nil, function(event)
if ( event.isError ) then
print( "Network error!" )
elseif ( event.phase == "began" ) then
print( "POST started" )
print ( "POST RESPONSE: " .. event.response )
elseif ( event.phase == "progress" ) then
print( "POST in progress" )
print ( "POST RESPONSE: " .. event.response )
elseif ( event.phase == "ended" ) then
print( "POST ended" )
print ( "POST RESPONSE: " .. event.response )
print("DELETE /users/test/0/")
db:delete("users/test/0/", nil, function(event)
if ( event.isError ) then
print( "Network error!" )
else
print ( "DELETE RESPONSE: " .. event.response )
if ( event.phase == "ended" ) then
print("GET /users/test/")
db:get("/users/test/", nil, function(event)
if ( event.isError ) then
print( "Network error!" )
else
print ( "GET RESPONSE: " .. event.response )
end
end)
end
end
end)
end
end)
print("DELETE")
db:delete("users/test", nil, function(event)
if ( event.isError ) then
print( "Network error!" )
else
print ( "DELETE RESPONSE: " .. event.response )
end
end)
print("---- AUTH tests ----")
print("NO AUTH GET")
db:get("", nil, function(event)
if ( event.isError ) then
print( "Network error!" )
else
print ( "NO AUTH GET RESPONSE: " .. event.response )
end
end)