Files
Gus Cairo 89888196dd Add missing availability (#228)
https://github.com/swift-server/swift-service-lifecycle/pull/227 added a
`ClosureService`, but we forgot to add availability guards to make sure
Swift Concurrency is available.
2026-02-20 17:06:14 +01:00

44 lines
1.2 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftServiceLifecycle open source project
//
// Copyright (c) 2026 Apple Inc. and the SwiftServiceLifecycle project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftServiceLifecycle project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import ServiceLifecycle
import Testing
struct ClosureServiceTests {
@Test
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
func runExecutesClosure() async throws {
try await confirmation { executed in
let service = ClosureService {
executed()
}
try await service.run()
}
}
@Test
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
func runPropagatesErrors() async {
struct TestError: Error {}
let service = ClosureService {
throw TestError()
}
await #expect(throws: TestError.self) {
try await service.run()
}
}
}