fix: set dokku system user in buildpacks unit tests
Pin DOKKU_SYSTEM_USER and DOKKU_SYSTEM_GROUP to the current process user in test setup so PropertyListWrite succeeds in CI Docker where the dokku group does not exist.
This commit is contained in:
@@ -2,6 +2,7 @@ package buildpacks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -15,9 +16,20 @@ func setupTestEnvironment(t *testing.T) string {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Setenv("DOKKU_LIB_ROOT", tmpDir)
|
t.Setenv("DOKKU_LIB_ROOT", tmpDir)
|
||||||
os.Setenv("PLUGIN_PATH", "/var/lib/dokku/plugins")
|
t.Setenv("PLUGIN_PATH", "/var/lib/dokku/plugins")
|
||||||
os.Setenv("PLUGIN_ENABLED_PATH", "/var/lib/dokku/plugins/enabled")
|
t.Setenv("PLUGIN_ENABLED_PATH", "/var/lib/dokku/plugins/enabled")
|
||||||
|
|
||||||
|
current, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
group, err := user.LookupGroupId(current.Gid)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Setenv("DOKKU_SYSTEM_USER", current.Username)
|
||||||
|
t.Setenv("DOKKU_SYSTEM_GROUP", group.Name)
|
||||||
|
|
||||||
return tmpDir
|
return tmpDir
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user