Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

test: make the update tests independent of platform layout

baiyuze302563f1331f
diff --git a/client-core/internal/update/update_test.go b/client-core/internal/update/update_test.go
index 9229faf..5d8eeba 100644
--- a/client-core/internal/update/update_test.go
+++ b/client-core/internal/update/update_test.go
@@ -18,6 +18,7 @@ import (
"net/http/httptest"
"os"
"path/filepath"
+ "runtime"
"strings"
"sync/atomic"
"testing"
@@ -254,8 +255,13 @@ func TestStageFolderFromZipAndTar(t *testing.T) {
if err := stageFolder(p, untar, "pasteferry", "pasteferryd"); err != nil {
t.Fatal(err)
}
- if st, err := os.Stat(filepath.Join(p.Staged, "pasteferryd")); err != nil || st.Mode().Perm()&0o100 == 0 {
- t.Fatalf("executable bit lost: %v %v", st, err)
+ st, err := os.Stat(filepath.Join(p.Staged, "pasteferryd"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ // Windows 没有可执行位;tar.gz 只在 Linux 上用
+ if runtime.GOOS != "windows" && st.Mode().Perm()&0o100 == 0 {
+ t.Fatalf("executable bit lost: %v", st.Mode())
}
// 缺少必需的文件时不留下解压的东西
p = &Plan{App: app, To: "2.3.3", Package: tgz}
diff --git a/ui/test/update_test.dart b/ui/test/update_test.dart
index 0fde5e3..7bbf9a7 100644
--- a/ui/test/update_test.dart
+++ b/ui/test/update_test.dart
@@ -182,7 +182,11 @@ void main() {
await tester.scrollUntilVisible(find.text('自动检查更新'), 200,
scrollable: find.descendant(of: page, matching: find.byType(Scrollable)).first);
final row = find.ancestor(of: find.text('自动检查更新'), matching: find.byType(SettingRow));
- await tester.tap(find.descendant(of: row, matching: find.byType(SmallSwitch)));
+ final toggle = find.descendant(of: row, matching: find.byType(SmallSwitch));
+ // 各平台的设置页行数不同:文字进入视野时开关可能还在屏幕边缘外
+ await tester.ensureVisible(toggle);
+ await tester.pumpAndSettle();
+ await tester.tap(toggle);
await tester.pumpAndSettle();
expect(state.config!.updateCheckDisabled, isTrue);
expect(state.autoCheckUpdates, isFalse);