mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
92f52ac406
* refactor: use t.Cleanup instead of defer Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * refactor: use t.Cleanup instead of defer Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * refactor: use t.Cleanup instead of defer Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * refactor: use t.Cleanup instead of defer Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: filepath Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
23 lines
493 B
Go
23 lines
493 B
Go
// Package testlib contains test helpers for goreleaser tests.
|
|
package testlib
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// Mktmp creates a new tempdir, cd into it and provides a back function that
|
|
// cd into the previous directory.
|
|
func Mktmp(t testing.TB) string {
|
|
var folder = t.TempDir()
|
|
current, err := os.Getwd()
|
|
require.NoError(t, err)
|
|
require.NoError(t, os.Chdir(folder))
|
|
t.Cleanup(func() {
|
|
require.NoError(t, os.Chdir(current))
|
|
})
|
|
return folder
|
|
}
|