返回 DeepSeek-Reasonix
local_save_replace_windows_test.go
根目录 / desktop / local_save_replace_windows_test.go
1 //go:build windows
2
3 package main
4
5 import (
6 "os"
7 "path/filepath"
8 "testing"
9 )
10
11 func TestReplaceLocalSaveDestinationFailurePreservesExistingTarget(t *testing.T) {
12 dir := t.TempDir()
13 target := filepath.Join(dir, "report.md")
14 original := []byte("existing destination")
15 if err := os.WriteFile(target, original, 0o600); err != nil {
16 t.Fatal(err)
17 }
18
19 missingTemp := filepath.Join(dir, "missing.reasonix-copy")
20 if err := replaceLocalSaveDestination(missingTemp, target); err == nil {
21 t.Fatal("replaceLocalSaveDestination with missing source succeeded, want error")
22 }
23 got, err := os.ReadFile(target)
24 if err != nil {
25 t.Fatalf("existing destination was removed after failed replacement: %v", err)
26 }
27 if string(got) != string(original) {
28 t.Fatalf("existing destination changed after failed replacement: got %q, want %q", got, original)
29 }
30 }
31
31 lines GO