diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-10-21 20:29:52 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-10-21 20:29:52 +0900 |
| commit | b1a4d801be033b41c559e9642ee05e2f0ec43d5b (patch) | |
| tree | c6792307b993c1fa715285518debb95c858630ef /hst/container_test.go | |
| parent | 56beae17fe7b208c144539821a3c34c395870372 (diff) | |
hst/container: flags string representation
This is useful for a user-facing representation other than JSON. This also gets rid of the ugly, outdated flags string builder in cmd/hakurei.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'hst/container_test.go')
| -rw-r--r-- | hst/container_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/hst/container_test.go b/hst/container_test.go index cdeb5023..df84827e 100644 --- a/hst/container_test.go +++ b/hst/container_test.go @@ -3,6 +3,7 @@ package hst_test import ( "encoding/json" "errors" + "math" "reflect" "syscall" "testing" @@ -10,6 +11,30 @@ import ( "hakurei.app/hst" ) +func TestFlagsString(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + flags hst.Flags + want string + }{ + {"none", 0, "none"}, + {"none high", hst.FAll + 1, "none"}, + {"all", hst.FAll, "multiarch, compat, devel, userns, net, abstract, tty, mapuid, device, runtime, tmpdir"}, + {"all high", math.MaxUint, "multiarch, compat, devel, userns, net, abstract, tty, mapuid, device, runtime, tmpdir"}, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + if got := tc.flags.String(); got != tc.want { + t.Errorf("String(%#b): %q, want %q", tc.flags, got, tc.want) + } + }) + } +} + func TestContainerConfig(t *testing.T) { t.Parallel() |
