Artifact 62e035b868213b286cf28f7368b7d33567517782939a8571d6d1e6a987347526:
- File
internal/branch/branch_test.go
— part of check-in
[6273a0750d]
at
2026-07-22 23:03:24
on branch trunk
— fix: correct go.mod module path to go-libfossil (#76) (#117)
* fix: correct go.mod module path to go-libfossil (#76)
The module directive still declared github.com/danmestas/libfossil after the repository was renamed to go-libfossil. pkg.go.dev/godoc scraping matches the declared module path against its hosting path, so the stale path broke SDK doc generation.
Rename the module path across all four in-repo modules (root, the two db/driver submodules, observer/otel, and docs/site) and every internal import, plus the release workflow, the doc-generation script, and the docs.
No tag has been published under the go-libfossil path yet, so the cross-module requires cannot resolve from the proxy. Add replace directives pointing the in-repo requires at their local directories so GOWORK=off builds and the CI matrix resolve without a published version. These replaces are ignored by downstream consumers and can be dropped once new-path tags are cut.
* Guard releases against replace directives; regenerate SDK docs
The go-libfossil rename bridges the in-repo modules with `replace` directives. Go refuses a main module that carries them, so a tag cut while they are present breaks `go install .../cmd/libfossil@<tag>` and every `@version` fetch of the driver submodules. Add a Release workflow step that fails the job before anything is published if any tracked go.mod still contains a replace directive, so the bridge is a CI-enforced TODO rather than a silent landmine. The step comment records what unblocks a release: re-tag the submodules with the corrected module paths, bump the root requires, then drop the replace blocks.
Regenerate the SDK reference docs. The previous pass only substituted URLs over the pre-existing generated files, leaving stale signatures (Repo.Timeline was still documented as taking LogOpts rather than TimelineOpts). Note that gomarkdoc must be run outside a git worktree — inside one it silently strips every source link.
Also reword the README rename note, which read as though the import path had not changed, and re-sort the ncruces require block. (user: [email protected], size: 3844) [annotate] [blame] [check-ins using]
package branch import ( "path/filepath" "testing" "time" "github.com/danmestas/go-libfossil/internal/manifest" "github.com/danmestas/go-libfossil/internal/repo" _ "github.com/danmestas/go-libfossil/internal/testdriver" "github.com/danmestas/go-libfossil/simio" ) func setupTestRepo(t *testing.T) *repo.Repo { t.Helper() path := filepath.Join(t.TempDir(), "test.fossil") r, err := repo.Create(path, "testuser", simio.CryptoRand{}, "") if err != nil { t.Fatalf("repo.Create: %v", err) } t.Cleanup(func() { r.Close() }) return r } func TestCreate(t *testing.T) { r := setupTestRepo(t) parentRid, _, err := manifest.Checkin(r, manifest.CheckinOpts{ Files: []manifest.File{{Name: "hello.txt", Content: []byte("hello")}}, Comment: "initial commit", User: "testuser", Time: time.Date(2024, 1, 15, 10, 0, 0, 0, time.UTC), }) if err != nil { t.Fatalf("Checkin: %v", err) } branchRid, _, err := Create(r, CreateOpts{ Name: "feature-x", Parent: parentRid, User: "testuser", Time: time.Date(2024, 1, 15, 11, 0, 0, 0, time.UTC), }) if err != nil { t.Fatalf("Create: %v", err) } if branchRid <= 0 { t.Fatalf("branchRid=%d, want > 0", branchRid) } // Verify branch tag. var branchValue string err = r.DB().QueryRow( "SELECT value FROM tagxref JOIN tag USING(tagid) WHERE tagname='branch' AND rid=?", branchRid, ).Scan(&branchValue) if err != nil { t.Fatalf("branch tag query: %v", err) } if branchValue != "feature-x" { t.Errorf("branch value=%q, want %q", branchValue, "feature-x") } // Verify sym-feature-x tag. var symCount int r.DB().QueryRow( "SELECT count(*) FROM tagxref JOIN tag USING(tagid) WHERE tagname='sym-feature-x' AND rid=?", branchRid, ).Scan(&symCount) if symCount != 1 { t.Errorf("sym-feature-x count=%d, want 1", symCount) } // Verify old sym-trunk cancelled on the branch checkin. var oldSymCount int r.DB().QueryRow( "SELECT count(*) FROM tagxref JOIN tag USING(tagid) WHERE tagname='sym-trunk' AND tagtype>0 AND rid=?", branchRid, ).Scan(&oldSymCount) if oldSymCount != 0 { t.Errorf("sym-trunk should be cancelled on branch, count=%d", oldSymCount) } } func TestList(t *testing.T) { r := setupTestRepo(t) parentRid, _, _ := manifest.Checkin(r, manifest.CheckinOpts{ Files: []manifest.File{{Name: "a.txt", Content: []byte("a")}}, Comment: "initial", User: "testuser", Time: time.Date(2024, 1, 15, 10, 0, 0, 0, time.UTC), }) Create(r, CreateOpts{Name: "feature-a", Parent: parentRid, User: "testuser", Time: time.Date(2024, 1, 15, 11, 0, 0, 0, time.UTC)}) Create(r, CreateOpts{Name: "feature-b", Parent: parentRid, User: "testuser", Time: time.Date(2024, 1, 15, 12, 0, 0, 0, time.UTC)}) branches, err := List(r) if err != nil { t.Fatalf("List: %v", err) } names := map[string]bool{} for _, b := range branches { names[b.Name] = true t.Logf("branch: %s closed=%v checkins=%d", b.Name, b.IsClosed, b.CheckinCount) } if !names["feature-a"] { t.Error("missing branch feature-a") } if !names["feature-b"] { t.Error("missing branch feature-b") } } func TestClose(t *testing.T) { r := setupTestRepo(t) parentRid, _, _ := manifest.Checkin(r, manifest.CheckinOpts{ Files: []manifest.File{{Name: "a.txt", Content: []byte("a")}}, Comment: "initial", User: "testuser", Time: time.Date(2024, 1, 15, 10, 0, 0, 0, time.UTC), }) Create(r, CreateOpts{Name: "done-branch", Parent: parentRid, User: "testuser", Time: time.Date(2024, 1, 15, 11, 0, 0, 0, time.UTC)}) if err := Close(r, "done-branch", "testuser"); err != nil { t.Fatalf("Close: %v", err) } branches, _ := List(r) for _, b := range branches { if b.Name == "done-branch" { if !b.IsClosed { t.Error("branch done-branch should be closed") } return } } t.Error("done-branch not found in List") }