@@ -3,24 +3,35 @@ import XCTest
33@testable import Functions
44
55final class FunctionInvokeOptionsTests : XCTestCase {
6- func testStringBody ( ) {
6+ func test_initWithStringBody ( ) {
77 let options = FunctionInvokeOptions ( body: " string value " )
88 XCTAssertEqual ( options. headers [ " Content-Type " ] , " text/plain " )
99 XCTAssertNotNil ( options. body)
1010 }
1111
12- func testDataBody ( ) {
12+ func test_initWithDataBody ( ) {
1313 let options = FunctionInvokeOptions ( body: " binary value " . data ( using: . utf8) !)
1414 XCTAssertEqual ( options. headers [ " Content-Type " ] , " application/octet-stream " )
1515 XCTAssertNotNil ( options. body)
1616 }
1717
18- func testEncodableBody ( ) {
18+ func test_initWithEncodableBody ( ) {
1919 struct Body : Encodable {
2020 let value : String
2121 }
2222 let options = FunctionInvokeOptions ( body: Body ( value: " value " ) )
2323 XCTAssertEqual ( options. headers [ " Content-Type " ] , " application/json " )
2424 XCTAssertNotNil ( options. body)
2525 }
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+ }
2637}
0 commit comments