Files
SpotiFLAC-Mobile/test/ios_container_paths_test.dart
T
zarzet aa99726439 feat(backend): migrate production backend to Rust
Replace the Go backend with the Rust workspace and route Android/iOS through
UniFFI bindings. Include the migrated extension runtime, network, providers,
media metadata, downloads and library operations, with version 5.0.0+147.

Remove Go sources, adapters, native build selection and CI dependencies.
Build Rust unconditionally and lock the iOS Rust pod using a relative path.
Retain legacy source and migration evidence in a local ignored archive.

Validation: Android Kotlin compile and 53 native tests; Swift Rust-branch
equivalence and syntax; CocoaPods install; workflow, shell, Ruby, plist and
diff checks. Reuse the preceding 100 Rust tests, fmt/Clippy and five-ABI
build checkpoint; no new APK or iOS application build for this cleanup.

Known follow-up: URL/URLSearchParams globals are missing from the Rust JS
runtime. A controlled extension replay confirms a URL-resolution regression;
this commit does not fix that runtime gap.
2026-09-14 22:58:27 +07:00

104 lines
3.6 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:spotiflac_android/utils/ios_container_paths.dart';
void main() {
group('rebaseIosSandboxPath', () {
const oldContainer =
'/var/mobile/Containers/Data/Application/'
'11111111-1111-4111-8111-111111111111';
const newDocuments =
'/var/mobile/Containers/Data/Application/'
'22222222-2222-4222-8222-222222222222/Documents';
const newContainer =
'/var/mobile/Containers/Data/Application/'
'22222222-2222-4222-8222-222222222222';
test('rebases supported device roots and preserves suffixes', () {
for (final root in const [
'Documents',
'Library/Application Support',
'Library/Caches',
]) {
for (final suffix in const [
'',
'/Music/曲 name #track01.flac',
'/Music/曲 name.flac#track01',
]) {
final oldPath = '$oldContainer/$root$suffix';
expect(
rebaseIosSandboxPath(oldPath, newDocuments),
'$newContainer/$root$suffix',
);
}
}
const privatePath =
'/private/var/mobile/Containers/Data/Application/'
'11111111-1111-4111-8111-111111111111/Documents/曲.flac';
expect(
rebaseIosSandboxPath(privatePath, newDocuments),
'$newContainer/Documents/曲.flac',
);
});
test('rebases simulator containers', () {
const oldPath =
'/Users/test/Library/Developer/CoreSimulator/Devices/'
'33333333-3333-4333-8333-333333333333/data/Containers/Data/'
'Application/55555555-5555-4555-8555-555555555555/'
'Documents/音楽 folder/song #track01.m4a';
const newDocuments =
'/Users/test/Library/Developer/CoreSimulator/Devices/'
'44444444-4444-4444-8444-444444444444/data/Containers/Data/'
'Application/66666666-6666-4666-8666-666666666666/'
'Documents';
final newContainer = newDocuments.substring(
0,
newDocuments.length - '/Documents'.length,
);
expect(
rebaseIosSandboxPath(oldPath, newDocuments),
'$newContainer/Documents/音楽 folder/song #track01.m4a',
);
});
test('is idempotent for the current container', () {
const currentPath =
'$newContainer/Documents/音楽 folder/song #track01.flac';
expect(rebaseIosSandboxPath(currentPath, newDocuments), currentPath);
});
test('leaves roots, traversal, URIs, and external paths unchanged', () {
const unchanged = [
oldContainer,
'$oldContainer/',
'$oldContainer/tmp/song.flac',
'$oldContainer/Documents/../Library/Caches/cover.jpg',
'$oldContainer/Documents-extra/song.flac',
'/outside$oldContainer/Documents/song.flac',
'/tmp/song.flac',
'content://downloads/song.flac',
'file:///var/mobile/Containers/Data/Application/OLD/song.flac',
'/data/user/0/com.example/files/song.flac',
'/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/song.flac',
'Documents/song.flac',
];
for (final path in unchanged) {
expect(rebaseIosSandboxPath(path, newDocuments), path);
}
});
test('requires a current iOS Documents directory', () {
const oldPath = '$oldContainer/Documents/song.flac';
for (final documents in const [
'',
'/Documents',
'/data/user/0/com.example/files/Documents',
'$newContainer/Documents/subfolder',
'$newContainer/Library/Application Support',
]) {
expect(rebaseIosSandboxPath(oldPath, documents), oldPath);
}
});
});
}