2
0

basic.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. local A = assert
  2. local c = uci.cursor(os.getenv("CONFIG_DIR"))
  3. c:foreach("network", "interface", function(s)
  4. print("---------------")
  5. for k, v in pairs(s) do
  6. print(k .. ': ' .. tostring(v))
  7. end
  8. end)
  9. local t = c:get_all("network")
  10. A(t.wan.ifname == 'eth1')
  11. A(t.wan.proto == 'dhcp')
  12. A(c:get("network", "wan", "ifname") == "eth1")
  13. A(c:get("network", "wan", "proto") == "dhcp")
  14. A(t.lan.ifname == 'eth0')
  15. A(t.lan.enabled == 'off')
  16. A(c:get("network", "lan", "ifname") == "eth0")
  17. A(c:get("network", "lan", "enabled") == "off")
  18. A(c:set("network", "lan", "ifname", "eth5"))
  19. A(c:get("network", "lan", "ifname") == "eth5")
  20. A(c:revert("network"))
  21. A(c:get("network", "lan", "ifname") == "eth0")
  22. A(c:set("network", "lan", "ifname", "eth5"))
  23. A(c:get("network", "lan", "ifname") == "eth5")
  24. A(c:commit("network"))
  25. A(c:set("network", "lan", "ifname", "eth0"))
  26. A(c:revert("network"))
  27. A(c:commit("network"))
  28. A(c:get("network", "lan", "ifname") == "eth5")
  29. A(c:set("network", "lan", "dns", {
  30. "ns1.king.banik.cz",
  31. "ns2.openwrt.org",
  32. }))
  33. local t = c:get("network", "lan", "dns")
  34. A(#t == 2)
  35. A(t[1] == "ns1.king.banik.cz")
  36. A(t[2] == "ns2.openwrt.org")
  37. print(c:get_all("broken"))