Artifact 8811bbc50bb75cf382843d02df96f50926d13e8a4fafbe038b6d9183b46a555b:
- File
observer_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: 1807) [annotate] [blame] [check-ins using]
package libfossil import "testing" func TestNopSyncObserverDoesNotPanic(t *testing.T) { o := NopSyncObserver() o.Started(SessionStart{ProjectCode: "test", Push: true, Pull: true}) o.RoundStarted(1) o.RoundCompleted(1, RoundStats{FilesSent: 1}) o.Completed(SessionEnd{Rounds: 1}) o.Error(nil) o.HandleStarted(HandleStart{RemoteAddr: "127.0.0.1"}) o.HandleCompleted(HandleEnd{FilesSent: 1, FilesRecvd: 2}) o.TableSyncStarted(TableSyncStart{Table: "config"}) o.TableSyncCompleted(TableSyncEnd{Table: "config", RowsSent: 5}) } func TestNopCheckoutObserverDoesNotPanic(t *testing.T) { o := NopCheckoutObserver() o.ExtractStarted(ExtractStart{RID: 1, Dir: "/tmp"}) o.ExtractFileCompleted("file.txt", ChangeAdded) o.ExtractCompleted(ExtractEnd{FilesWritten: 1}) o.ScanStarted("/tmp") o.ScanCompleted(ScanEnd{FilesScanned: 5}) o.CommitStarted(CommitStart{Comment: "test", User: "user", Files: 1}) o.CommitCompleted(CommitEnd{UUID: "abc123", RID: 1}) o.Error(nil) } func TestStdoutSyncObserverDoesNotPanic(t *testing.T) { o := StdoutSyncObserver() o.Started(SessionStart{}) o.RoundStarted(1) o.RoundCompleted(1, RoundStats{}) o.Completed(SessionEnd{}) o.Error(nil) o.HandleStarted(HandleStart{}) o.HandleCompleted(HandleEnd{}) o.TableSyncStarted(TableSyncStart{}) o.TableSyncCompleted(TableSyncEnd{}) } func TestStdoutCheckoutObserverDoesNotPanic(t *testing.T) { o := StdoutCheckoutObserver() o.ExtractStarted(ExtractStart{}) o.ExtractFileCompleted("file.txt", ChangeAdded) o.ExtractCompleted(ExtractEnd{}) o.ScanStarted("/tmp") o.ScanCompleted(ScanEnd{}) o.CommitStarted(CommitStart{}) // Test with empty UUID (guard against panic on UUID[:10]) o.CommitCompleted(CommitEnd{UUID: "", RID: 1}) o.CommitCompleted(CommitEnd{UUID: "abcdef1234567890", RID: 2}) o.Error(nil) }