@@ -3,24 +3,35 @@ import XCTest
3
3
@testable import Functions
4
4
5
5
final class FunctionInvokeOptionsTests : XCTestCase {
6
- func testStringBody ( ) {
6
+ func test_initWithStringBody ( ) {
7
7
let options = FunctionInvokeOptions ( body: " string value " )
8
8
XCTAssertEqual ( options. headers [ " Content-Type " ] , " text/plain " )
9
9
XCTAssertNotNil ( options. body)
10
10
}
11
11
12
- func testDataBody ( ) {
12
+ func test_initWithDataBody ( ) {
13
13
let options = FunctionInvokeOptions ( body: " binary value " . data ( using: . utf8) !)
14
14
XCTAssertEqual ( options. headers [ " Content-Type " ] , " application/octet-stream " )
15
15
XCTAssertNotNil ( options. body)
16
16
}
17
17
18
- func testEncodableBody ( ) {
18
+ func test_initWithEncodableBody ( ) {
19
19
struct Body : Encodable {
20
20
let value : String
21
21
}
22
22
let options = FunctionInvokeOptions ( body: Body ( value: " value " ) )
23
23
XCTAssertEqual ( options. headers [ " Content-Type " ] , " application/json " )
24
24
XCTAssertNotNil ( options. body)
25
25
}
26
+
27
+ func test_initWithCustomContentType( ) {
28
+ let boundary = " Boundary- \( UUID ( ) . uuidString) "
29
+ let contentType = " multipart/form-data; boundary= \( boundary) "
30
+ let options = FunctionInvokeOptions (
31
+ headers: [ " Content-Type " : contentType] ,
32
+ body: " binary value " . data ( using: . utf8) !
33
+ )
34
+ XCTAssertEqual ( options. headers [ " Content-Type " ] , contentType)
35
+ XCTAssertNotNil ( options. body)
36
+ }
26
37
}
0 commit comments