Skip to content

Commit

Permalink
include mac verification in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
javierajorge committed Oct 10, 2023
1 parent f6aa83f commit 6d4c609
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function get_bat_links_info()
batneights_obj = JSON.parse(batneights)

for key,neight_value in pairs (batneights_obj) do
macparts = network.get_mac(neight_value.iface)
src_macaddr = table.concat(macparts,":")
local macparts = network.get_mac(neight_value.iface)
local src_macaddr = table.concat(macparts,":")
neight_value.hard_ifindex=nil
neight_value.src_mac=src_macaddr
for key,link_value in pairs (batlinks_obj) do
Expand All @@ -49,7 +49,6 @@ function get_bat_links_info()
end
end
end
utils.printJson(batneights_obj)
return batneights_obj
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ describe('Tests bat_links_info #bat_links_info', function ()
}
]
]]

stub(utils, "unsafe_shell", function (cmd)
if cmd == "batctl nj" then
return nj_output
Expand All @@ -180,17 +181,22 @@ describe('Tests bat_links_info #bat_links_info', function ()
end
return ""
end)

stub(network, "get_mac", function (iface)
if string.match(iface, "wlan0") then
return iwinfo.mocks.wlan0_mesh_mac
end
return iwinfo.mocks.wlan1_mesh_mac
end)

package.path = package.path .. ";packages/shared-state-bat_links_info/files/usr/bin/?;;"
require ("shared-state-publish_bat_links_info")

it('a simple test to get node info and assert requiered fields are present', function()
local links_info = {}
links_info = get_bat_links_info()
assert.are.equal(table.concat(iwinfo.mocks.wlan1_mesh_mac,":"), links_info[1].src_mac)
assert.are.equal(table.concat(iwinfo.mocks.wlan0_mesh_mac,":"), links_info[1].src_mac)
assert.are.equal(table.concat(iwinfo.mocks.wlan1_mesh_mac,":"), links_info[4].src_mac)
assert.are.equal('02:58:47:da:4e:aa', links_info[1].dst_mac)
assert.are.equal(1040, links_info[1].last_seen_msecs)
assert.are.equal("wlan0-mesh_250", links_info[1].iface)
Expand Down

0 comments on commit 6d4c609

Please sign in to comment.