aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/config_test.go
diff options
context:
space:
mode:
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