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) } } }