beads/cmd/bd/database_name_test.go
Okano, Osamu fef73917cc
fix(gate): keep dry-run checks write-free
* fix(gate): avoid await_id writes during dry-run check (beads-0vhw)

intent(gate): keep bd gate check --dry-run preview-only even when gh:run gates use workflow-name hints
decision(gate-check): thread a persistDiscoveredRunID flag through checkGHRun so dry-run can reuse discovery without calling UpdateIssue
constraint(gate-check): close and non-dry-run gate evaluation still need to persist discovered numeric run IDs for later checks

* fix(cmd): share sanitizeDBName across build tags (beads-nyfc)

intent(cmd-init): keep no-cgo lint and hook runs from failing on init.go's sanitizeDBName reference
decision(build-tags): move sanitizeDBName into an untagged helper file and move its unit test beside it so cgo and no-cgo builds compile the same symbol
constraint(testing): leave cgo-specific store migration tests in store_factory_test.go while the shared helper test lives outside build tags

* Add gate check coverage for workflow discovery persistence

* test(gate): cover extracted gh run status helper

intent(gate-check): cover the extracted gh run status helper so the PR no longer leaves the Codecov patch line uncovered
decision(gate-tests): reuse cmd/bd/gate_test.go with a PATH-injected fake gh binary instead of adding a broader integration case
2026-04-24 07:53:13 -07:00

27 lines
672 B
Go

package main
import "testing"
// TestSanitizeDBName lives in an untagged file so both cgo and no-cgo builds
// compile and verify the shared helper.
func TestSanitizeDBName(t *testing.T) {
tests := []struct {
input string
want string
}{
{"my-project", "my_project"},
{"jtbot-core", "jtbot_core"},
{"no-hyphens-here", "no_hyphens_here"},
{"dots.and-hyphens", "dots_and_hyphens"},
{"already_clean", "already_clean"},
{"beads", "beads"},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
got := sanitizeDBName(tt.input)
if got != tt.want {
t.Errorf("sanitizeDBName(%q) = %q, want %q", tt.input, got, tt.want)
}
})
}
}