Artifact f137d59e7b01b89ebd79f5ca2e11249307447783e270e7c1b9668c9d2da0b3d3:
- File
internal/auth/auth_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: 1415) [annotate] [blame] [check-ins using]
package auth import "testing" func TestHasCapability(t *testing.T) { tests := []struct { caps string required byte want bool }{ {"oi", 'o', true}, {"oi", 'i', true}, {"oi", 'g', false}, {"", 'o', false}, {"cghijknorswy", 's', true}, {"cghijknorswy", 'a', false}, } for _, tt := range tests { got := HasCapability(tt.caps, tt.required) if got != tt.want { t.Errorf("HasCapability(%q, %q) = %v, want %v", tt.caps, tt.required, got, tt.want) } } } func TestCanPush(t *testing.T) { if !CanPush("oi") { t.Error("CanPush(oi) should be true") } if CanPush("o") { t.Error("CanPush(o) should be false") } } func TestCanPull(t *testing.T) { if !CanPull("oi") { t.Error("CanPull(oi) should be true") } if CanPull("i") { t.Error("CanPull(i) should be false") } } func TestCanClone(t *testing.T) { if !CanClone("g") { t.Error("CanClone(g) should be true") } if CanClone("oi") { t.Error("CanClone(oi) should be false") } } func TestCanPushUV(t *testing.T) { if !CanPushUV("y") { t.Error("CanPushUV(y) should be true") } if CanPushUV("oi") { t.Error("CanPushUV(oi) should be false") } } func TestCanSyncPrivate(t *testing.T) { if !CanSyncPrivate("x") { t.Error("CanSyncPrivate(x) should be true") } if CanSyncPrivate("oi") { t.Error("CanSyncPrivate(oi) should be false") } if CanSyncPrivate("as") { t.Error("CanSyncPrivate(as) should be false — x must be explicit") } }