Files
OpsLog/bulkfields_test.go
T
rouggy 2a6e09a1d7 fix(bulk): mode and RST were offered but could not be saved
A bulk-editable field passes through THREE tables: the list the dialog shows,
bulkFieldColumns in app.go, and bulkEditableCols in internal/qso. I added mode,
submode and RST to the first and the third and missed the middle one, so the
dialog offered them and every save came back "unknown field".

Nothing warns about that. Each table is perfectly valid on its own, and the
mismatch only surfaces when an operator picks the one field that falls through
the gap — which is exactly how it was found.

So both directions are pinned now: every mapped field must be writable by the
qso layer, and every writable column must have a field mapping to it. A column
nothing maps to looks supported from the inside and cannot be reached from
outside, which is the same fault wearing the other hat.
2026-08-11 20:39:46 +02:00

36 lines
1.1 KiB
Go

package main
import (
"testing"
"hamlog/internal/qso"
)
// A bulk-editable field passes through THREE tables: the field list in the UI,
// bulkFieldColumns here, and bulkEditableCols in internal/qso. Mode and RST were
// added to the first and the third and not the second, so the dialog offered
// them and the save failed with "unknown field" — reported from the field.
//
// Nothing warns about that: each table is valid on its own. This is the check.
func TestEveryMappedBulkFieldIsWhitelisted(t *testing.T) {
for id, col := range bulkFieldColumns {
if !qso.BulkEditable(col) {
t.Errorf("bulk field %q maps to column %q, which internal/qso refuses to write", id, col)
}
}
}
// And the reverse: a column the qso layer allows but nothing maps to is dead
// weight — it looks supported from the inside and cannot be reached from outside.
func TestNoUnreachableBulkColumn(t *testing.T) {
mapped := map[string]bool{}
for _, col := range bulkFieldColumns {
mapped[col] = true
}
for _, col := range qso.BulkEditableColumns() {
if !mapped[col] {
t.Errorf("column %q is bulk-writable but no field maps to it — unreachable", col)
}
}
}