package pskr import ( "encoding/json" "testing" ) // The frequency has to survive from the payload to the Spot: the Chase New // panel is only useful if a click can put the rig on the station, and a row // showing "—" instead of 14074.0 is a row nobody can act on. func TestWirePayloadCarriesFrequency(t *testing.T) { const payload = `{"sq":1,"f":14074123,"md":"FT8","rp":-12,"sc":"VK9XX","sl":"QH30","rc":"F4BPO","rl":"IN95","b":"20m"}` var p wire if err := json.Unmarshal([]byte(payload), &p); err != nil { t.Fatalf("unmarshal: %v", err) } if p.Freq != 14074123 { t.Errorf("Freq = %d, want 14074123", p.Freq) } if p.TxCall != "VK9XX" || p.Band != "20m" || p.Mode != "FT8" { t.Errorf("unexpected decode: %+v", p) } // And the Spot the watcher builds must carry it — this is the field that was // declared, documented, and then never assigned. s := Spot{Call: p.TxCall, Band: p.Band, Mode: p.Mode, FreqHz: p.Freq} if s.FreqHz != p.Freq { t.Errorf("Spot.FreqHz = %d, want %d", s.FreqHz, p.Freq) } }