mirror of
https://github.com/dokku/dokku.git
synced 2026-07-10 04:23:59 +02:00
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 (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -15,9 +16,20 @@ func setupTestEnvironment(t *testing.T) string {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
os.Setenv("DOKKU_LIB_ROOT", tmpDir)
|
||||
os.Setenv("PLUGIN_PATH", "/var/lib/dokku/plugins")
|
||||
os.Setenv("PLUGIN_ENABLED_PATH", "/var/lib/dokku/plugins/enabled")
|
||||
t.Setenv("DOKKU_LIB_ROOT", tmpDir)
|
||||
t.Setenv("PLUGIN_PATH", "/var/lib/dokku/plugins")
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user