chore(ci): include date-time in temp dir name used for tests (#4651)

While sorting by modification time is possible with OS tools,
such as `ls`, including the directory creation time in the
name facilitates cleanup in local dev environments where
tests fail often.
This commit is contained in:
Julio Lopez
2025-06-04 20:07:05 -07:00
committed by GitHub
parent 4af09ff2d6
commit 81539eee8f

View File

@@ -7,6 +7,7 @@
"path/filepath"
"strings"
"testing"
"time"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
@@ -24,7 +25,7 @@
// GetInterestingTempDirectoryName returns interesting directory name used for testing.
func GetInterestingTempDirectoryName() (string, error) {
td, err := os.MkdirTemp("", "kopia-test")
td, err := os.MkdirTemp("", "kopia-test-"+time.Now().UTC().Format("20060102-150405")) //nolint:forbidigo
if err != nil {
return "", errors.Wrap(err, "unable to create temp directory")
}
@@ -73,7 +74,7 @@ func TempDirectory(tb testing.TB) string {
func TempDirectoryShort(tb testing.TB) string {
tb.Helper()
d, err := os.MkdirTemp("", "kopia-test")
d, err := os.MkdirTemp("", "kopia-test-"+time.Now().UTC().Format("20060102-150405")) //nolint:forbidigo
if err != nil {
tb.Fatal(errors.Wrap(err, "unable to create temp directory"))
}