Some checks failed
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m8s
Test / Hakurei (push) Failing after 3m9s
Test / Hpkg (push) Successful in 4m6s
Test / Sandbox (race detector) (push) Successful in 4m25s
Test / Hakurei (race detector) (push) Successful in 5m1s
Test / Flake checks (push) Has been skipped
This will never return true otherwise unless the equivalent paths happen to be interned by the caller. Signed-off-by: Ophestra <cat@gensokyo.uk>
82 lines
1.6 KiB
Go
82 lines
1.6 KiB
Go
package container
|
|
|
|
import "testing"
|
|
|
|
func TestAutoRootOp(t *testing.T) {
|
|
checkOpsBuilder(t, []opsBuilderTestCase{
|
|
{"pd", new(Ops).Root(MustAbs("/"), "048090b6ed8f9ebb10e275ff5d8c0659", BindWritable), Ops{
|
|
&AutoRootOp{
|
|
Host: MustAbs("/"),
|
|
Prefix: "048090b6ed8f9ebb10e275ff5d8c0659",
|
|
Flags: BindWritable,
|
|
},
|
|
}},
|
|
})
|
|
|
|
checkOpIs(t, []opIsTestCase{
|
|
{"zero", new(AutoRootOp), new(AutoRootOp), false},
|
|
|
|
{"internal ne", &AutoRootOp{
|
|
Host: MustAbs("/"),
|
|
Prefix: ":3",
|
|
Flags: BindWritable,
|
|
}, &AutoRootOp{
|
|
Host: MustAbs("/"),
|
|
Prefix: ":3",
|
|
Flags: BindWritable,
|
|
resolved: []Op{new(BindMountOp)},
|
|
}, true},
|
|
|
|
{"differs", &AutoRootOp{
|
|
Host: MustAbs("/"),
|
|
Prefix: "\x00",
|
|
Flags: BindWritable,
|
|
}, &AutoRootOp{
|
|
Host: MustAbs("/"),
|
|
Prefix: ":3",
|
|
Flags: BindWritable,
|
|
}, false},
|
|
|
|
{"equals", &AutoRootOp{
|
|
Host: MustAbs("/"),
|
|
Prefix: ":3",
|
|
Flags: BindWritable,
|
|
}, &AutoRootOp{
|
|
Host: MustAbs("/"),
|
|
Prefix: ":3",
|
|
Flags: BindWritable,
|
|
}, true},
|
|
})
|
|
|
|
checkOpMeta(t, []opMetaTestCase{
|
|
{"root", &AutoRootOp{
|
|
Host: MustAbs("/"),
|
|
Prefix: ":3",
|
|
Flags: BindWritable,
|
|
}, "setting up", `auto root "/" prefix :3 flags 0x2`},
|
|
})
|
|
}
|
|
|
|
func TestIsAutoRootBindable(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
want bool
|
|
}{
|
|
{"proc", false},
|
|
{"dev", false},
|
|
{"tmp", false},
|
|
{"mnt", false},
|
|
{"etc", false},
|
|
{"", false},
|
|
|
|
{"var", true},
|
|
}
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := IsAutoRootBindable(tc.name); got != tc.want {
|
|
t.Errorf("IsAutoRootBindable: %v, want %v", got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|