Files
OpsLog/rxdefaults_test.go
T
rouggy ab8ecd65fe test(adif): assert FREQ_RX reaches the forwarded record too
The fix filled both halves of the receive side, but the test only proved
BAND_RX came out the other end. FREQ_RX is the half the question was
really about.
2026-08-31 22:30:32 +02:00

43 lines
1.4 KiB
Go

package main
import (
"strings"
"testing"
"hamlog/internal/adif"
"hamlog/internal/qso"
)
// A contact that was not split still has a receive side, and the record
// forwarded to another logger has to carry it: Log4OM reads BAND_RX.
func TestFillRXDefaults(t *testing.T) {
hz := int64(14074000)
q := qso.QSO{Callsign: "F4BPO", Band: "20m", FreqHz: &hz}
fillRXDefaults(&q)
if q.BandRX != "20m" {
t.Errorf("BandRX = %q, want 20m", q.BandRX)
}
if q.FreqRXHz == nil || *q.FreqRXHz != hz {
t.Errorf("FreqRXHz = %v, want %d", q.FreqRXHz, hz)
}
// Assert on the RECORD another logger reads, not merely on the struct:
// both halves of the receive side have to reach it.
rec := strings.ToUpper(adif.SingleRecordADIF(q))
if !strings.Contains(rec, "<BAND_RX:3>20M") {
t.Errorf("BAND_RX missing from the forwarded record:\n%s", rec)
}
if !strings.Contains(rec, "<FREQ_RX:9>14.074000") {
t.Errorf("FREQ_RX missing from the forwarded record:\n%s", rec)
}
}
// A genuine split contact keeps what it was given.
func TestFillRXDefaultsKeepsSplit(t *testing.T) {
tx, rx := int64(14195000), int64(14205000)
q := qso.QSO{Callsign: "F4BPO", Band: "20m", BandRX: "17m", FreqHz: &tx, FreqRXHz: &rx}
fillRXDefaults(&q)
if q.BandRX != "17m" || q.FreqRXHz == nil || *q.FreqRXHz != rx {
t.Errorf("split QSO was overwritten: band_rx=%q freq_rx=%v", q.BandRX, q.FreqRXHz)
}
}