Artifact a76d7abbb42646826cb479cc47c8997fda0c598371e546591f3c71ca510d59b1:
- File
fossil_test.go
— part of check-in
[f5744359d3]
at
2026-04-19 16:30:54
on branch trunk
— Initial open source release
libfossil is a pure-Go implementation of the Fossil SCM, reading and writing the same .fossil SQLite repository format as upstream Fossil.
This is the first public release of code that previously lived in a private repository. The module path is github.com/danmestas/libfossil and the binary is named libfossil to avoid $PATH collisions with upstream fossil.
Included: - Repo lifecycle (create, clone), checkout/checkin, timeline, merge, diff, annotate, shun, tag, branch, bisect, stash, undo/redo - Sync-over-HTTP protocol (client and handler) - Two SQLite drivers: modernc (pure Go, default) and ncruces (wasm-capable) - Observer interfaces (SyncObserver, CheckoutObserver) with an optional OpenTelemetry implementation in observer/otel (separate submodule) - Deterministic simulation testing harness with BUGGIFY fault injection - Kong-based embeddable CLI under cli/ and a standalone binary under cmd/libfossil/ (user: [email protected], size: 1175) [annotate] [blame] [check-ins using]
package libfossil import ( "os" "path/filepath" "testing" _ "github.com/danmestas/libfossil/internal/testdriver" ) func TestCreateAndOpen(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "test.fossil") r, err := Create(path, CreateOpts{User: "test"}) if err != nil { t.Fatal(err) } if r.Path() != path { t.Errorf("Path() = %q, want %q", r.Path(), path) } if err := r.Close(); err != nil { t.Fatal(err) } if _, err := os.Stat(path); err != nil { t.Fatal("repo file should exist after Create") } r2, err := Open(path) if err != nil { t.Fatal(err) } defer r2.Close() if r2.Path() != path { t.Errorf("Path() = %q, want %q", r2.Path(), path) } } func TestCreateAlreadyExists(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "test.fossil") r, err := Create(path, CreateOpts{User: "test"}) if err != nil { t.Fatal(err) } r.Close() _, err = Create(path, CreateOpts{User: "test"}) if err == nil { t.Error("Create on existing repo should fail") } } func TestOpenNotFound(t *testing.T) { _, err := Open("/nonexistent/path.fossil") if err == nil { t.Error("Open on nonexistent path should fail") } }