feat(spot): put the award references in the spot comment
After the mode, which is the order a cluster line is read in: "CW POTA FR-11553". Two sources, because the QSO can be at either stage. While it is being typed the entry panel holds the references as "CODE@REF;CODE@REF"; once logged they live on the row as the materialised award_refs. The Send Spot window takes the entry's when there are any and falls back to the last logged QSO — the same fallback the callsign and frequency defaults already use — and picking a QSO from the Latest list fills in that QSO's own. A self-spot is the opposite case and gets its own builder: it announces OUR station, so it carries MY_POTA_REF and friends. Using the QSO's award references there would spot us with the park number of the station we just worked, announcing us from somewhere we are not. Both cap at the 30 characters a cluster node keeps, and add a reference whole or not at all — a truncated park number is worse than none, since nobody can act on it, and it still costs everyone who reads the spot. Only the comment we BUILD is held to that; what the operator types is their own business.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"hamlog/internal/qso"
|
||||
)
|
||||
|
||||
// A self-spot announces OUR station, so it must carry the references we are
|
||||
// activating (MY_POTA_REF…), never the QSO's award references — those belong to
|
||||
// the station we worked, and spotting yourself with someone else's park number
|
||||
// puts you somewhere you are not.
|
||||
func TestSelfSpotComment(t *testing.T) {
|
||||
for name, c := range map[string]struct {
|
||||
q qso.QSO
|
||||
want string
|
||||
}{
|
||||
"mode only": {
|
||||
q: qso.QSO{Mode: "cw"},
|
||||
want: "CW",
|
||||
},
|
||||
"my park": {
|
||||
q: qso.QSO{Mode: "SSB", MyPOTARef: "fr-11553"},
|
||||
want: "SSB POTA FR-11553",
|
||||
},
|
||||
"two references": {
|
||||
q: qso.QSO{Mode: "CW", MyPOTARef: "FR-11553", MySOTARef: "F/AM-123"},
|
||||
want: "CW POTA FR-11553 SOTA F/AM-123",
|
||||
},
|
||||
// 30 characters is all a cluster keeps. The third reference is dropped
|
||||
// whole rather than cut in half.
|
||||
"too long drops the extra": {
|
||||
q: qso.QSO{
|
||||
Mode: "CW", MyPOTARef: "FR-11553", MySOTARef: "F/AM-123",
|
||||
MyWWFFRef: "FFF-0123",
|
||||
},
|
||||
want: "CW POTA FR-11553 SOTA F/AM-123",
|
||||
},
|
||||
// A QSO's own award references are the DX's, and must not leak in.
|
||||
"dx references are not ours": {
|
||||
q: qso.QSO{Mode: "FT8", POTARef: "US-0001", AwardRefs: `{"POTA":"US-0001"}`},
|
||||
want: "FT8",
|
||||
},
|
||||
} {
|
||||
if got := selfSpotComment(c.q); got != c.want {
|
||||
t.Errorf("%s: got %q, want %q", name, got, c.want)
|
||||
}
|
||||
if got := selfSpotComment(c.q); len(got) > spotCommentMax {
|
||||
t.Errorf("%s: %d characters, over the %d a cluster keeps", name, len(got), spotCommentMax)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user