import Foundation import ParcelConfig import Testing @testable import ParcelApp @MainActor @Suite("Activity app storage") struct AppActivityTests { @Test func productionStorageLivesInApplicationSupport() { guard ProcessInfo.processInfo.environment["PARCEL_ACTIVITY_PATH"] == nil else { return } let url = NativeAppRuntime.activityFileURL( configURL: URL(fileURLWithPath: "/isolated/parcel.toml"), isolated: false) #expect(url == URL.applicationSupportDirectory.appendingPathComponent("dev.vinnymac.parcel/activity.json")) } @Test func fixtureStorageStaysBesideItsIsolatedConfig() { guard ProcessInfo.processInfo.environment["PARCEL_ACTIVITY_PATH"] == nil else { return } let url = NativeAppRuntime.activityFileURL( configURL: URL(fileURLWithPath: "/isolated/parcel.toml"), isolated: true) #expect(url.path == "/isolated/activity.json") } @Test func injectedWorldWithDefaultConfigNeverUsesRealUserStorage() { let url = NativeAppRuntime.activityFileURL(configURL: ConfigStore.defaultFileURL, isolated: true) let scratch = URL(fileURLWithPath: FileManager.default.currentDirectoryPath).appendingPathComponent( ".build/activity-tests/") #expect(url.path.hasPrefix(scratch.path)) #expect(url.lastPathComponent == "activity.json") #expect(!FileManager.default.fileExists(atPath: url.path)) } }