From 5770c40d8902a78c4aa6e409a38a1dab34e9a40b Mon Sep 17 00:00:00 2001 From: Gregory Salaun Date: Sun, 16 Aug 2026 10:06:30 +0200 Subject: [PATCH] test(adif): pin that an import invents no QSL routing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported as OpsLog defaulting QSL_SENT_VIA and QSL_RCVD_VIA to "E" on import. It does not: recordToQSO reads the field and normalises it, so an absent, empty, blank or unrecognised value gives an empty one. An "E" seen after an import came from the file — Log4OM writes QSL_SENT_VIA:1>E on every record whether a card was ever sent, which TestQSLSentViaDoesNotBecomeManager already pins. Nothing to change, so this pins the half nothing covered: the ABSENCE case. The opposite is an easy reach — electronic confirmation is the common case — and defaulting to it would quietly rewrite the operator's own record of how their cards travelled, which is the same class of fault as issue #16. Compiles and vets clean; not executed here — this machine's Application Control policy began blocking freshly built test binaries partway through the session. --- internal/adif/qslvia_import_test.go | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 internal/adif/qslvia_import_test.go diff --git a/internal/adif/qslvia_import_test.go b/internal/adif/qslvia_import_test.go new file mode 100644 index 0000000..e67b0fa --- /dev/null +++ b/internal/adif/qslvia_import_test.go @@ -0,0 +1,41 @@ +package adif + +import ( + "strings" + "testing" +) + +// An import must never INVENT a routing method. The two "via" fields carry what +// the file carries, and nothing at all when it carries nothing. +// +// This is worth pinning because the opposite is easy to reach for: a card that +// was confirmed electronically is the common case, and defaulting to E would +// quietly rewrite the operator's own record of how their cards actually +// travelled. Where an E does show up after an import, it came from the source +// file — Log4OM writes QSL_SENT_VIA:1>E on every record whether or not a card +// was ever sent, which is pinned by TestQSLSentViaDoesNotBecomeManager. +func TestImportInventsNoQSLRouting(t *testing.T) { + for name, rec := range map[string]string{ + "absent": "OE6CLD20260606120020mCW\n", + "empty": "OE6CLD20260606120020mCW\n", + "whitespace": "OE6CLD20260606120020mCW \n", + // Not in the enumeration: dropped rather than passed through, or the + // export would write a value no other logger can read. + "unknown": "OE6CLD20260606120020mCWZZZ\n", + } { + var got Record + if err := Parse(strings.NewReader("\n"+rec), func(r Record) error { got = r; return nil }); err != nil { + t.Fatalf("%s: parse: %v", name, err) + } + q, ok := recordToQSO(got) + if !ok { + t.Fatalf("%s: recordToQSO returned !ok", name) + } + if q.QSLSentVia != "" { + t.Errorf("%s: QSL_SENT_VIA = %q, want empty — the import made up a routing method", name, q.QSLSentVia) + } + if q.QSLRcvdVia != "" { + t.Errorf("%s: QSL_RCVD_VIA = %q, want empty — the import made up a routing method", name, q.QSLRcvdVia) + } + } +}