feat(awards): match on CNTY as it stands, not only keyed to a US state
The award field list offered us_county, which returns STATE,County -- correct for the United States, where Jefferson County exists in several states, and wrong for every award whose district is already unique. An RDA reference (RO-19) never matched, and there was no other field to point an award at. Adds county, the raw CNTY value, alongside it.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package award
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"hamlog/internal/qso"
|
||||
)
|
||||
|
||||
// A district lives in CNTY as-is; the US award field keys it to the state
|
||||
// because county names repeat across states. Confusing the two silently breaks
|
||||
// whichever award is not American.
|
||||
func TestCountyFieldIsRawWhileUSCountyIsKeyed(t *testing.T) {
|
||||
q := &qso.QSO{State: "TX", County: "RO-19"}
|
||||
if got := fieldRaw("county", q); got != "RO-19" {
|
||||
t.Fatalf("county = %q, want RO-19", got)
|
||||
}
|
||||
if got := fieldRaw("us_county", q); got == "RO-19" {
|
||||
t.Fatalf("us_county should key the county to its state, got %q", got)
|
||||
}
|
||||
var found bool
|
||||
for _, f := range Fields() {
|
||||
if f == "county" {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("county missing from the award field list")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user