Files
cheat/internal/cheatpath/writeable_test.go
Christopher Allen Lane 5ad1a3c39f chore: housekeeping and refactoring (bump to 4.7.1)
- Remove unused parameters, dead files, and inaccurate doc.go files
- Extract shared helpers, eliminate duplication
- Rename cheatpath.Cheatpath to cheatpath.Path
- Optimize filesystem walks (WalkDir, skip .git)
- Move sheet name validation to sheet.Validate
- Move integration tests to test/integration/
- Consolidate internal/mock into mocks/
- Move fuzz.sh to test/
- Inline loadSheets helper into command callers
- Extract config.New into its own file
- Fix stale references in HACKING.md and CLAUDE.md
- Restore plan9 build target
- Remove redundant and low-value tests
- Clean up project documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 15:11:19 -05:00

51 lines
1.2 KiB
Go

package cheatpath
import (
"testing"
)
// TestWriteableOK asserts that Writeable returns the appropriate cheatpath
// when a writeable cheatpath exists
func TestWriteableOK(t *testing.T) {
// initialize some cheatpaths
cheatpaths := []Path{
Path{Path: "/foo", ReadOnly: true},
Path{Path: "/bar", ReadOnly: false},
Path{Path: "/baz", ReadOnly: true},
}
// get the writeable cheatpath
got, err := Writeable(cheatpaths)
// assert that no errors were returned
if err != nil {
t.Errorf("failed to get cheatpath: %v", err)
}
// assert that the path is correct
if got.Path != "/bar" {
t.Errorf("incorrect cheatpath returned: got: %s", got.Path)
}
}
// TestWriteableOK asserts that Writeable returns an error when no writeable
// cheatpaths exist
func TestWriteableNotOK(t *testing.T) {
// initialize some cheatpaths
cheatpaths := []Path{
Path{Path: "/foo", ReadOnly: true},
Path{Path: "/bar", ReadOnly: true},
Path{Path: "/baz", ReadOnly: true},
}
// get the writeable cheatpath
_, err := Writeable(cheatpaths)
// assert that no errors were returned
if err == nil {
t.Errorf("failed to return an error when no writeable paths found")
}
}