aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/config_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-07 01:50:56 +0900
committerOphestra <cat@gensokyo.uk>2025-10-07 04:24:45 +0900
commit9e48d7f5626aa966a23754534f3120855d6a7c32 (patch)
treeade6eb09abd52b4c64bb5eb9dfb5246ee93454fe /hst/config_test.go
parentf280994957bdc1c6defdd4bd9dcc44dd83a5cfd5 (diff)
hst/config: move container fields from toplevel
This change also moves pd behaviour to cmd/hakurei, as this does not belong in the hst API. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'hst/config_test.go')
-rw-r--r--hst/config_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/hst/config_test.go b/hst/config_test.go
index c8da8a25..98321c73 100644
--- a/hst/config_test.go
+++ b/hst/config_test.go
@@ -1,12 +1,49 @@
package hst_test
import (
+ "reflect"
"testing"
"hakurei.app/container"
"hakurei.app/hst"
)
+func TestConfigValidate(t *testing.T) {
+ testCases := []struct {
+ name string
+ config *hst.Config
+ wantErr error
+ }{
+ {"nil", nil, &hst.AppError{Step: "validate configuration", Err: hst.ErrConfigNull,
+ Msg: "invalid configuration"}},
+ {"container", &hst.Config{}, &hst.AppError{Step: "validate configuration", Err: hst.ErrConfigNull,
+ Msg: "configuration missing container state"}},
+ {"home", &hst.Config{Container: &hst.ContainerConfig{}}, &hst.AppError{Step: "validate configuration", Err: hst.ErrConfigNull,
+ Msg: "container configuration missing path to home directory"}},
+ {"shell", &hst.Config{Container: &hst.ContainerConfig{
+ Home: container.AbsFHSTmp,
+ }}, &hst.AppError{Step: "validate configuration", Err: hst.ErrConfigNull,
+ Msg: "container configuration missing path to shell"}},
+ {"path", &hst.Config{Container: &hst.ContainerConfig{
+ Home: container.AbsFHSTmp,
+ Shell: container.AbsFHSTmp,
+ }}, &hst.AppError{Step: "validate configuration", Err: hst.ErrConfigNull,
+ Msg: "container configuration missing path to initial program"}},
+ {"valid", &hst.Config{Container: &hst.ContainerConfig{
+ Home: container.AbsFHSTmp,
+ Shell: container.AbsFHSTmp,
+ Path: container.AbsFHSTmp,
+ }}, nil},
+ }
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ if err := tc.config.Validate(); !reflect.DeepEqual(err, tc.wantErr) {
+ t.Errorf("Validate: error = %#v, want %#v", err, tc.wantErr)
+ }
+ })
+ }
+}
+
func TestExtraPermConfig(t *testing.T) {
testCases := []struct {
name string