test(adif): pin that an import invents no QSL routing
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.
This commit is contained in:
@@ -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": "<CALL:5>OE6CLD<QSO_DATE:8>20260606<TIME_ON:4>1200<BAND:3>20m<MODE:2>CW<EOR>\n",
|
||||||
|
"empty": "<CALL:5>OE6CLD<QSO_DATE:8>20260606<TIME_ON:4>1200<BAND:3>20m<MODE:2>CW<QSL_SENT_VIA:0><QSL_RCVD_VIA:0><EOR>\n",
|
||||||
|
"whitespace": "<CALL:5>OE6CLD<QSO_DATE:8>20260606<TIME_ON:4>1200<BAND:3>20m<MODE:2>CW<QSL_SENT_VIA:1> <QSL_RCVD_VIA:1> <EOR>\n",
|
||||||
|
// Not in the enumeration: dropped rather than passed through, or the
|
||||||
|
// export would write a value no other logger can read.
|
||||||
|
"unknown": "<CALL:5>OE6CLD<QSO_DATE:8>20260606<TIME_ON:4>1200<BAND:3>20m<MODE:2>CW<QSL_SENT_VIA:3>ZZZ<EOR>\n",
|
||||||
|
} {
|
||||||
|
var got Record
|
||||||
|
if err := Parse(strings.NewReader("<EOH>\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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user