mirror of
https://github.com/anchore/syft.git
synced 2026-11-05 08:56:41 +01:00
27 lines
393 B
Go
27 lines
393 B
Go
package testutil
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Chdir(t *testing.T, dir string) {
|
|
t.Helper()
|
|
|
|
wd, err := os.Getwd()
|
|
if err != nil {
|
|
t.Fatalf("unable to get working directory: %v", err)
|
|
}
|
|
|
|
err = os.Chdir(dir)
|
|
if err != nil {
|
|
t.Fatalf("unable to chdir to '%s': %v", dir, err)
|
|
}
|
|
|
|
t.Cleanup(func() {
|
|
require.NoError(t, os.Chdir(wd))
|
|
})
|
|
}
|