Skip to content

Commit

Permalink
chore: fix persistent storage tests for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-fiedler committed Feb 2, 2024
1 parent acdab95 commit 2bf130b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Tests/AmplitudeTests/Storages/PersistentStorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,26 @@ final class PersistentStorageTests: XCTestCase {
}

#if os(macOS)
func testMacOsStorageDirectorySandboxedWhenAppSandboxDisabled() {
let persistentStorage = PersistentStorage(storagePrefix: "mac-instance")

let bundleId = Bundle.main.bundleIdentifier!
let storageUrl = persistentStorage.getEventsStorageDirectory(createDirectory: false)

XCTAssertEqual(persistentStorage.sandboxHelper.isSandboxEnabled(), false)
XCTAssertEqual(storageUrl.absoluteString.contains(bundleId), true)
persistentStorage.reset()
}

func testMacOsStorageDirectorySandboxedWhenAppSandboxEnabled() {
let persistentStorage = PersistentStorage(storagePrefix: "app-sandbox-instance")
let persistentStorage = PersistentStorage(storagePrefix: "mac-app-sandbox-instance")
persistentStorage.sandboxHelper = FakeSandboxHelperWithAppSandboxContainer()

let bundleId = Bundle.main.bundleIdentifier!
let storageUrl = persistentStorage.getEventsStorageDirectory(createDirectory: false)

XCTAssertEqual(storageUrl.absoluteString.contains(bundleId), true)
XCTAssertEqual(persistentStorage.sandboxHelper.isSandboxEnabled(), true)
XCTAssertEqual(storageUrl.absoluteString.contains(bundleId), false)
persistentStorage.reset()
}
#endif
Expand Down

0 comments on commit 2bf130b

Please sign in to comment.