debian-forge-composer/cmd/osbuild-worker-executor/export_test.go
Michael Vogt fc1d1c3b8f osbuild-worker-executor: job-id in control.json as hostname
This commit adds support to set the hostname to the job-id that
is part of the control.json.
2024-06-14 15:02:08 +02:00

38 lines
634 B
Go

package main
import (
"os"
"path/filepath"
"testing"
)
var (
Run = run
HandleIncludedSources = handleIncludedSources
)
func MockUnixSethostname(new func([]byte) error) (restore func()) {
saved := unixSethostname
unixSethostname = new
return func() {
unixSethostname = saved
}
}
func MockOsbuildBinary(t *testing.T, new string) (restore func()) {
t.Helper()
saved := osbuildBinary
tmpdir := t.TempDir()
osbuildBinary = filepath.Join(tmpdir, "fake-osbuild")
/* #nosec G306 */
if err := os.WriteFile(osbuildBinary, []byte(new), 0755); err != nil {
t.Fatal(err)
}
return func() {
osbuildBinary = saved
}
}