cantabile_edge, cantabile_modbus, cantabile_eebus 0.1.629: full source

This commit is contained in:
Setti Solutions S.R.L committed 2026-11-03 23:26:41 +02:00
1 parent d5fbcacaa4
commit 85edd56ec8
46 files changed
+3518 -267

No files matched your search

+21
View File
@@ -23,3 +23,24 @@ func TestSetupDone(t *testing.T) {
t.Fatal("not a bool")
}
}
// The heartbeat's location: country and postcode (never lat/lon), "at".
func TestBoxLocation(t *testing.T) {
p := filepath.Join(t.TempDir(), "config.json")
if boxLocation(p) != nil {
t.Fatal("no file: none")
}
os.WriteFile(p, []byte(`{"location": {"country": "DE", "postal_code": "10115", "latitude": 52.53, "longitude": 13.38, "at": 1761800000}}`), 0o600)
l := boxLocation(p)
if l["country"] != "DE" || l["postal_code"] != "10115" || l["at"] != int64(1761800000) || l["latitude"] != nil || len(l) != 3 {
t.Fatalf("%v", l)
}
os.WriteFile(p, []byte(`{"location": {"country": "AT"}}`), 0o600)
if l := boxLocation(p); l["country"] != "AT" || l["postal_code"] != "" || l["at"] != nil {
t.Fatalf("%v", l)
}
os.WriteFile(p, []byte(`{"location": {"latitude": 1}}`), 0o600)
if boxLocation(p) != nil {
t.Fatal("no country: none")
}
}