-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathLambdaRuntimeTests.swift
52 lines (43 loc) · 1.55 KB
/
LambdaRuntimeTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftAWSLambdaRuntime open source project
//
// Copyright (c) 2025 Apple Inc. and the SwiftAWSLambdaRuntime project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
import Logging
import NIOCore
import Synchronization
import Testing
@testable import AWSLambdaRuntime
@Suite("LambdaRuntimeTests")
final class LambdaRuntimeTests {
@Test("LambdaRuntime can only be initialized once")
func testLambdaRuntimeInitializationFatalError() throws {
// First initialization should succeed
try _ = LambdaRuntime(handler: MockHandler(), eventLoop: Lambda.defaultEventLoop, logger: Logger(label: "Test"))
// Second initialization should trigger LambdaRuntimeError
#expect(throws: LambdaRuntimeError.self) {
try _ = LambdaRuntime(
handler: MockHandler(),
eventLoop: Lambda.defaultEventLoop,
logger: Logger(label: "Test")
)
}
}
}
struct MockHandler: StreamingLambdaHandler {
mutating func handle(
_ event: NIOCore.ByteBuffer,
responseWriter: some AWSLambdaRuntime.LambdaResponseStreamWriter,
context: AWSLambdaRuntime.LambdaContext
) async throws {
}
}