Artifact 4e1346a43f0be34d6e2de643319306453bddc58ef8943a7e113a61874b22904f:
- File
errors_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: 1273) [annotate] [blame] [check-ins using]
package libfossil import ( "errors" "testing" ) func TestFslErrorCode(t *testing.T) { err := &FslError{Code: RCNotARepo, Msg: "not a repo"} if err.Code != RCNotARepo { t.Fatalf("Code = %d, want %d", err.Code, RCNotARepo) } } func TestFslErrorImplementsError(t *testing.T) { var err error = &FslError{Code: RCDB, Msg: "db error"} got := err.Error() want := "fossil(db): db error" if got != want { t.Fatalf("Error() = %q, want %q", got, want) } } func TestFslErrorUnwrap(t *testing.T) { inner := errors.New("sqlite: constraint") err := &FslError{Code: RCDB, Msg: "insert failed", Cause: inner} if !errors.Is(err, inner) { t.Fatal("FslError should unwrap to its Cause") } } func TestRCCodeString(t *testing.T) { tests := []struct { code RC want string }{ {RCOK, "ok"}, {RCError, "error"}, {RCOOM, "oom"}, {RCMisuse, "misuse"}, {RCRange, "range"}, {RCAccess, "access"}, {RCIO, "io"}, {RCNotFound, "not_found"}, {RCAlreadyExists, "already_exists"}, {RCConsistency, "consistency"}, {RCNotARepo, "not_a_repo"}, {RCDB, "db"}, {RCChecksumMismatch, "checksum_mismatch"}, } for _, tt := range tests { if got := tt.code.String(); got != tt.want { t.Errorf("RC(%d).String() = %q, want %q", tt.code, got, tt.want) } } }