Artifact a4c0d3622b483bd79b024a8f012958a1002aa8191ae7a598c8999af98241e4cc:
- File
internal/path/path_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: 3740) [annotate] [blame] [check-ins using]
package path import ( "database/sql" "testing" libdb "github.com/danmestas/go-libfossil/db" libfossil "github.com/danmestas/go-libfossil/internal/fsltype" _ "github.com/danmestas/go-libfossil/internal/testdriver" ) // buildPlink creates an in-memory SQLite DB with plink table and populates it. // Each edge is [3]interface{}{pid, cid, isprim}. func buildPlink(t *testing.T, edges [][3]int) *sql.DB { t.Helper() db, err := sql.Open(libdb.RegisteredDriver().Name, ":memory:") if err != nil { t.Fatal(err) } _, err = db.Exec(`CREATE TABLE plink( pid INTEGER, cid INTEGER, isprim BOOLEAN, mtime REAL, UNIQUE(pid, cid)); CREATE INDEX plink_i2 ON plink(cid, pid)`) if err != nil { t.Fatal(err) } for _, e := range edges { _, err := db.Exec("INSERT INTO plink(pid, cid, isprim) VALUES(?,?,?)", e[0], e[1], e[2]) if err != nil { t.Fatal(err) } } t.Cleanup(func() { db.Close() }) return db } func TestLinearChain(t *testing.T) { // 1->2->3->4->5 db := buildPlink(t, [][3]int{ {1, 2, 1}, {2, 3, 1}, {3, 4, 1}, {4, 5, 1}, }) path, err := Shortest(db, 1, 5, false, nil) if err != nil { t.Fatal(err) } if len(path) != 5 { t.Fatalf("expected length 5, got %d: %v", len(path), rids(path)) } expect := []libfossil.FslID{1, 2, 3, 4, 5} for i, n := range path { if n.RID != expect[i] { t.Errorf("path[%d] = %d, want %d", i, n.RID, expect[i]) } } } func TestDiamondMerge(t *testing.T) { // 1->2(prim), 1->3(merge), 2->4(prim), 3->4(merge) db := buildPlink(t, [][3]int{ {1, 2, 1}, {1, 3, 0}, {2, 4, 1}, {3, 4, 0}, }) path, err := Shortest(db, 1, 4, false, nil) if err != nil { t.Fatal(err) } if len(path) != 3 { t.Fatalf("expected length 3, got %d: %v", len(path), rids(path)) } } func TestDirectOnly(t *testing.T) { // 1->2(prim), 1->3(merge), 3->4(prim) db := buildPlink(t, [][3]int{ {1, 2, 1}, {1, 3, 0}, {3, 4, 1}, }) // directOnly=true: can't cross 1->3 merge edge, so no path 1->4 _, err := Shortest(db, 1, 4, true, nil) if err != ErrNoPath { t.Fatalf("expected ErrNoPath with directOnly=true, got %v", err) } // directOnly=false: 1->3->4 works path, err := Shortest(db, 1, 4, false, nil) if err != nil { t.Fatal(err) } if len(path) != 3 { t.Fatalf("expected length 3, got %d: %v", len(path), rids(path)) } } func TestSkipSet(t *testing.T) { // 1->2->3->4, skip node 3 db := buildPlink(t, [][3]int{ {1, 2, 1}, {2, 3, 1}, {3, 4, 1}, }) skip := map[libfossil.FslID]bool{3: true} _, err := Shortest(db, 1, 4, false, skip) if err != ErrNoPath { t.Fatalf("expected ErrNoPath with skip={3}, got %v", err) } } func TestNoPath(t *testing.T) { // disconnected: 1->2, 3->4 db := buildPlink(t, [][3]int{ {1, 2, 1}, {3, 4, 1}, }) _, err := Shortest(db, 1, 4, false, nil) if err != ErrNoPath { t.Fatalf("expected ErrNoPath, got %v", err) } } func TestReversePath(t *testing.T) { // 1->2->3, find 3 to 1 (walk backwards via reverse edges) db := buildPlink(t, [][3]int{ {1, 2, 1}, {2, 3, 1}, }) path, err := Shortest(db, 3, 1, false, nil) if err != nil { t.Fatal(err) } if len(path) != 3 { t.Fatalf("expected length 3, got %d: %v", len(path), rids(path)) } expect := []libfossil.FslID{3, 2, 1} for i, n := range path { if n.RID != expect[i] { t.Errorf("path[%d] = %d, want %d", i, n.RID, expect[i]) } } } func TestSameNode(t *testing.T) { db := buildPlink(t, [][3]int{{1, 2, 1}}) path, err := Shortest(db, 1, 1, false, nil) if err != nil { t.Fatal(err) } if len(path) != 1 || path[0].RID != 1 { t.Fatalf("expected single node [1], got %v", rids(path)) } } func rids(path []PathNode) []libfossil.FslID { out := make([]libfossil.FslID, len(path)) for i, n := range path { out[i] = n.RID } return out }