hst/fs: valid method on underlying interface
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 1m59s
Test / Hakurei (push) Successful in 3m6s
Test / Hpkg (push) Successful in 4m16s
Test / Sandbox (race detector) (push) Successful in 4m24s
Test / Hakurei (race detector) (push) Successful in 5m7s
Test / Flake checks (push) Successful in 1m39s

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-08-14 21:36:22 +09:00
parent c989e7785a
commit 0e543a58b3
6 changed files with 38 additions and 22 deletions

View File

@@ -144,7 +144,7 @@ func TestFilesystemConfigJSON(t *testing.T) {
t.Errorf("Valid: %v, want false", got)
}
if got := (&hst.FilesystemConfigJSON{FilesystemConfig: new(hst.FSBind)}).Valid(); !got {
if got := (&hst.FilesystemConfigJSON{FilesystemConfig: &hst.FSBind{Src: m("/etc")}}).Valid(); !got {
t.Errorf("Valid: %v, want true", got)
}
})
@@ -192,6 +192,7 @@ type stubFS struct {
}
func (s stubFS) Type() string { return s.typeName }
func (s stubFS) Valid() bool { return false }
func (s stubFS) Target() *container.Absolute { panic("unreachable") }
func (s stubFS) Host() []*container.Absolute { panic("unreachable") }
func (s stubFS) Apply(*container.Ops) { panic("unreachable") }
@@ -205,6 +206,7 @@ type sCheck struct {
type fsTestCase struct {
name string
fs hst.FilesystemConfig
valid bool
ops container.Ops
target *container.Absolute
host []*container.Absolute
@@ -214,9 +216,17 @@ type fsTestCase struct {
func checkFs(t *testing.T, fstype string, testCases []fsTestCase) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if got := tc.fs.Type(); got != fstype {
t.Errorf("Type: %q, want %q", got, fstype)
}
t.Run("type", func(t *testing.T) {
if got := tc.fs.Type(); got != fstype {
t.Errorf("Type: %q, want %q", got, fstype)
}
})
t.Run("valid", func(t *testing.T) {
if got := tc.fs.Valid(); got != tc.valid {
t.Errorf("Valid: %v, want %v", got, tc.valid)
}
})
t.Run("ops", func(t *testing.T) {
ops := new(container.Ops)