feat: per-file example tests — action, registry, fs, api, string, path, service, error, array
33 new examples across 8 dedicated files. Removed phantom CleanPath
(in RFC spec but never implemented — spec drift caught by examples).
545 tests total, 84.8% coverage. Every major primitive has compilable
examples that serve as test, documentation seed, and godoc content.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 18:29:24 +00:00
|
|
|
package core_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
. "dappco.re/go/core"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func ExampleJoinPath() {
|
|
|
|
|
fmt.Println(JoinPath("deploy", "to", "homelab"))
|
|
|
|
|
// Output: deploy/to/homelab
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ExamplePathBase() {
|
|
|
|
|
fmt.Println(PathBase("/srv/workspaces/alpha"))
|
|
|
|
|
// Output: alpha
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ExamplePathDir() {
|
|
|
|
|
fmt.Println(PathDir("/srv/workspaces/alpha"))
|
|
|
|
|
// Output: /srv/workspaces
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ExamplePathExt() {
|
|
|
|
|
fmt.Println(PathExt("report.pdf"))
|
|
|
|
|
// Output: .pdf
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-25 18:34:39 +00:00
|
|
|
func ExampleCleanPath() {
|
|
|
|
|
fmt.Println(CleanPath("/tmp//file", "/"))
|
|
|
|
|
fmt.Println(CleanPath("a/b/../c", "/"))
|
|
|
|
|
fmt.Println(CleanPath("deploy/to/homelab", "/"))
|
|
|
|
|
// Output:
|
|
|
|
|
// /tmp/file
|
|
|
|
|
// a/c
|
|
|
|
|
// deploy/to/homelab
|
|
|
|
|
}
|
|
|
|
|
|