e2e/testutils: SetupPlugin: return path of directory

The gotest.tools `fs.NewDir` utility already sets up a `t.Cleanup`,
so we can treat it the same as `t.TempDir()` and let it handle
cleaning up by itself.

We should probably consider replacing some of this with `t.TempDir`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-05 10:18:10 +02:00
parent f2c64c123f
commit 081add2fc5
3 changed files with 9 additions and 11 deletions

View File

@ -22,8 +22,10 @@ import (
var plugins embed.FS
// SetupPlugin builds a plugin and creates a temporary
// directory with the plugin's config.json and rootfs.
func SetupPlugin(t *testing.T, ctx context.Context) *fs.Dir {
// directory with the plugin's config.json and rootfs,
// which will be removed in [t.Cleanup]. It returns
// the location of the temporary directory.
func SetupPlugin(t *testing.T, ctx context.Context) (pluginDir string) {
t.Helper()
p := &plugin.Config{
@ -52,7 +54,7 @@ func SetupPlugin(t *testing.T, ctx context.Context) *fs.Dir {
)
icmd.RunCommand("/bin/cp", binPath, dir.Join("rootfs", p.Entrypoint[0])).Assert(t, icmd.Success)
return dir
return dir.Path()
}
// buildPlugin uses Go to build a plugin from one of the source files in the plugins directory.