Files
ARTEX/server/task_archive_journal_test.go
T
BaaRai 3593297664 fix(server): do not fsync the journal directory on Windows
writeRemoteArchiveJournal ended with Sync on two directory handles.
Windows cannot flush a directory handle, so the journal write failed
there and no remote archive or remote deletion could start.

Move the directory sync to syncDir: the unix build keeps the fsync, the
other builds return nil (the journal file itself is already synced).
2026-11-20 21:13:55 +01:00

28 lines
802 B
Go

package server
import (
"encoding/json"
"os"
"testing"
)
// Writing the journal must succeed on every platform the server builds for. It
// needs no database: on Windows the directory sync it ended with failed, so no
// remote archive or remote deletion could start.
func TestRemoteArchiveJournalWrite(t *testing.T) {
s := &Server{m: &Manager{dir: t.TempDir()}}
want := remoteArchiveJournal{ArchiveID: 7, URI: "s3://bucket/tasks/package.tar.zst", LocalPath: "package.tar.zst", Operation: "upload"}
name, err := s.writeRemoteArchiveJournal(want)
if err != nil {
t.Fatal(err)
}
raw, err := os.ReadFile(name)
if err != nil {
t.Fatal(err)
}
var got remoteArchiveJournal
if err := json.Unmarshal(raw, &got); err != nil || got != want {
t.Fatalf("journal content %q: %v", raw, err)
}
}