Tests/OrgCoreTests/SandboxTests.swift

25119f4b2ffb63711ac162144288a075b8e1fe7d
orgstar/Tests/OrgCoreTests/SandboxTests.swift

33 lines · 1309 bytes

 1import Foundation
 2import Testing
 3@testable import OrgCore
 4
 5struct SandboxTests {
 6    /// Tests run unsandboxed, so every switch keeps the Developer ID build's behaviour.
 7    @Test func inactiveInTests() {
 8        #expect(!Sandbox.isActive)
 9        #expect(Sandbox.bookmarkCreationOptions() == [])
10        #expect(Sandbox.bookmarkResolutionOptions() == [])
11    }
12
13    @Test func detectedFromTheContainerVariable() {
14        #expect(!Sandbox.isActive(environment: [:]))
15        #if os(macOS)
16        #expect(Sandbox.isActive(environment: ["APP_SANDBOX_CONTAINER_ID": "sh.krz.orgstar"]))
17        #else
18        #expect(!Sandbox.isActive(environment: ["APP_SANDBOX_CONTAINER_ID": "sh.krz.orgstar"]))
19        #endif
20    }
21
22    @Test func bookmarksAreSecurityScopedInTheMacSandbox() {
23        #if os(macOS)
24        #expect(Sandbox.bookmarkCreationOptions(sandboxed: true) == .withSecurityScope)
25        #expect(Sandbox.bookmarkResolutionOptions(sandboxed: true) == .withSecurityScope)
26        #else
27        #expect(Sandbox.bookmarkCreationOptions(sandboxed: true) == [])
28        #expect(Sandbox.bookmarkResolutionOptions(sandboxed: true) == [])
29        #endif
30        #expect(Sandbox.bookmarkCreationOptions(sandboxed: false) == [])
31        #expect(Sandbox.bookmarkResolutionOptions(sandboxed: false) == [])
32    }
33}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form