|
@@ -41,3 +41,44 @@ func TestCommonUnixValidateConfigurationErrors(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestCommonUnixGetInitPath(t *testing.T) {
|
|
|
+ testCases := []struct {
|
|
|
+ config *Config
|
|
|
+ expectedInitPath string
|
|
|
+ }{
|
|
|
+ {
|
|
|
+ config: &Config{
|
|
|
+ InitPath: "some-init-path",
|
|
|
+ },
|
|
|
+ expectedInitPath: "some-init-path",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ config: &Config{
|
|
|
+ CommonUnixConfig: CommonUnixConfig{
|
|
|
+ DefaultInitBinary: "foo-init-bin",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ expectedInitPath: "foo-init-bin",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ config: &Config{
|
|
|
+ InitPath: "init-path-A",
|
|
|
+ CommonUnixConfig: CommonUnixConfig{
|
|
|
+ DefaultInitBinary: "init-path-B",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ expectedInitPath: "init-path-A",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ config: &Config{},
|
|
|
+ expectedInitPath: "docker-init",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, tc := range testCases {
|
|
|
+ initPath := tc.config.GetInitPath()
|
|
|
+ if initPath != tc.expectedInitPath {
|
|
|
+ t.Fatalf("expected initPath to be %v, got %v", tc.expectedInitPath, initPath)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|