mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 14:00:29 +00:00
fix(tests): resolve flaky ID generation and symlink resolution on macOS
This commit is contained in:
@@ -369,8 +369,14 @@ func TestSymlinkResolution(t *testing.T) {
|
||||
t.Fatalf("EvalSymlinks failed: %v", err)
|
||||
}
|
||||
|
||||
if resolved != realFile {
|
||||
t.Errorf("EvalSymlinks(%q) = %q, want %q", linkFile, resolved, realFile)
|
||||
// Normalize realFile in case tmpDir itself contains symlinks (e.g. /var -> /private/var on macOS)
|
||||
realFileResolved, err := filepath.EvalSymlinks(realFile)
|
||||
if err != nil {
|
||||
t.Fatalf("EvalSymlinks on realFile failed: %v", err)
|
||||
}
|
||||
|
||||
if resolved != realFileResolved {
|
||||
t.Errorf("EvalSymlinks(%q) = %q, want %q", linkFile, resolved, realFileResolved)
|
||||
}
|
||||
|
||||
// Verify temp file in same dir as resolved path allows rename
|
||||
|
||||
@@ -6,12 +6,13 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// GenerateID generates a unique ID with the given prefix
|
||||
func GenerateID(prefix string) string {
|
||||
return fmt.Sprintf("%s-%d", prefix, time.Now().UnixNano())
|
||||
return fmt.Sprintf("%s-%s", prefix, uuid.NewString())
|
||||
}
|
||||
|
||||
// WriteJSONResponse writes a JSON response to the http.ResponseWriter
|
||||
|
||||
Reference in New Issue
Block a user