Skip to content

Commit a96e81a

Browse files
committed
specs back to green
1 parent 2fc8e5b commit a96e81a

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

spec/application_spec.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe("application", function()
66
if name == "actuators" then
77
return {{pin=1,trigger=1} }
88
elseif name == "settings" then
9-
return {apiUrl = "http://192.168.1.123:8123/api/konnected", token = "secrettoken"}
9+
return {endpoint = "http://192.168.1.123:8123/api/konnected", token = "secrettoken"}
1010
else
1111
return real_require(name)
1212
end

spec/device_spec.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ describe("device", function()
77
end)
88

99
it("has expected properties", function()
10-
assert.equal(device.swVersion, "2.2.6")
11-
assert.equal(device.hwVersion, "2.2.6")
10+
assert.equal(device.swVersion, "2.3.1")
11+
assert.equal(device.hwVersion, "2.3.0")
1212
assert.equal(device.name, "Konnected")
1313
end)
1414

spec/init_spec.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe("init", function()
1717
nodemcu.wifi.sta.config = ""
1818
mock(_G.enduser_setup)
1919

20-
dofile("src/init.lua")
20+
dofile("../init.lua")
2121
end)
2222

2323
after_each(function()
@@ -35,7 +35,7 @@ describe("init", function()
3535
before_each(function()
3636
require("spec/nodemcu_stubs")
3737
stub(_G.tmr, 'create').returns(mock_timer)
38-
dofile("src/init.lua")
38+
dofile("../init.lua")
3939

4040
spy.on(_G.gpio, 'write')
4141
spy.on(wifi.eventmon, 'unregister')
@@ -81,7 +81,7 @@ describe("init", function()
8181
before_each(function()
8282
require("spec/nodemcu_stubs")
8383
stub(_G.tmr, 'create').returns(mock_timer)
84-
dofile("src/init.lua")
84+
dofile("../init.lua")
8585
spy.on(wifi.eventmon, 'unregister')
8686

8787
nodemcu.wifi.eventmon['STA_DISCONNECTED']({SSID = "test", BSSID = "test", reason = "201"})

spec/nodemcu_stubs.lua

+26
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ _G.node = {
2525
heap = function() return 0 end,
2626
chipid = function() return 0 end,
2727
restart = function() end,
28+
flashindex = function() return true end,
29+
flashreload = function() end,
2830
info = function() return 1, 5, 4 end
2931
}
3032

@@ -126,6 +128,30 @@ _G.unpack = function(t, i)
126128
end
127129
end
128130

131+
_G.sntp = {
132+
sync = function(_, success, fail)
133+
success()
134+
end
135+
}
136+
137+
_G.rtctime = {
138+
epoch2cal = function()
139+
return {
140+
year = 2019,
141+
mon = 9,
142+
day = 17,
143+
hour = 17,
144+
min = 46,
145+
sec = 58
146+
}
147+
end
148+
}
149+
150+
local df = dofile
151+
_G.dofile = function(n)
152+
df('src/lfs/' .. n)
153+
end
154+
129155
-- Print contents of `tbl`, with indentation.
130156
-- `indent` sets the initial level of indentation.
131157
function tprint (tbl, indent)

src/lfs/server_device.lua

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
local module = ...
2-
local switch = require("switch")
32

43
local function process(request)
54
if request.method == "GET" then
@@ -26,11 +25,11 @@ local function process(request)
2625
if request.body[1] then
2726
local ret = {}
2827
for i in pairs(request.body) do
29-
table.insert(ret, switch(request.body[i]))
28+
table.insert(ret, require("switch")(request.body[i]))
3029
end
3130
return sjson.encode(ret)
3231
else
33-
return sjson.encode(switch(request.body))
32+
return sjson.encode(require("switch")(request.body))
3433
end
3534
end
3635
end

0 commit comments

Comments
 (0)