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:
Jose Diaz-Gonzalez
2026-07-07 19:57:03 -04:00
parent 16f8b25bda
commit c8bcba0145

View File

@@ -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
}