浏览代码

Make the test expectations on `receive` consistent across Linux and macOS.

Daniel Alm 7 年之前
父节点
当前提交
c9620048f5
共有 2 个文件被更改,包括 8 次插入24 次删除
  1. 2 11
      Tests/SwiftGRPCTests/ServerThrowingTests.swift
  2. 6 13
      Tests/SwiftGRPCTests/ServerTimeoutTests.swift

+ 2 - 11
Tests/SwiftGRPCTests/ServerThrowingTests.swift

@@ -98,7 +98,7 @@ extension ServerThrowingTests {
       completionHandlerExpectation.fulfill()
     }
     
-    // TODO(danielalm): Why doesn't `call.receive()` throw once the call times out?
+    // FIXME(danielalm): Why does `call.receive()` essentially return "end of stream", rather than returning an error?
     XCTAssertNil(try! call.receive())
     
     waitForExpectations(timeout: defaultTimeout)
@@ -120,17 +120,8 @@ extension ServerThrowingTests {
     }
     call.waitForSendOperationsToFinish()
     
-    // FIXME(danielalm): Why does `call.receive()` only throw on Linux (but not macOS) once the call times out?
-    #if os(Linux)
-    do {
-      _ = try call.receive()
-      XCTFail("should have thrown")
-    } catch let receiveError {
-      XCTAssertEqual(.unknown, (receiveError as! RPCError).callResult!.statusCode)
-    }
-    #else
+    // FIXME(danielalm): Why does `call.receive()` essentially return "end of stream", rather than returning an error?
     XCTAssertNil(try! call.receive())
-    #endif
     
     waitForExpectations(timeout: defaultTimeout)
   }

+ 6 - 13
Tests/SwiftGRPCTests/ServerTimeoutTests.swift

@@ -81,8 +81,8 @@ extension ServerTimeoutTests {
     call.waitForSendOperationsToFinish()
     
     do {
-      _ = try call.closeAndReceive()
-      XCTFail("should have thrown")
+      let result = try call.closeAndReceive()
+      XCTFail("should have thrown, instead received \(result)")
     } catch let receiveError {
       XCTAssertEqual(.unknown, (receiveError as! RPCError).callResult!.statusCode)
     }
@@ -97,7 +97,8 @@ extension ServerTimeoutTests {
       completionHandlerExpectation.fulfill()
     }
     
-    // TODO(danielalm): Why doesn't `call.receive()` throw once the call times out?
+    // FIXME(danielalm): Why does `call.receive()` essentially return "end of stream" once the call times out,
+    // rather than returning an error?
     XCTAssertNil(try! call.receive())
     
     waitForExpectations(timeout: defaultTimeout)
@@ -118,17 +119,9 @@ extension ServerTimeoutTests {
     }
     call.waitForSendOperationsToFinish()
     
-    // FIXME(danielalm): Why does `call.receive()` only throw on Linux (but not macOS) once the call times out?
-    #if os(Linux)
-    do {
-      _ = try call.receive()
-      XCTFail("should have thrown")
-    } catch let receiveError {
-      XCTAssertEqual(.unknown, (receiveError as! RPCError).callResult!.statusCode)
-    }
-    #else
+    // FIXME(danielalm): Why does `call.receive()` essentially return "end of stream" once the call times out,
+    // rather than returning an error?
     XCTAssertNil(try! call.receive())
-    #endif
     
     waitForExpectations(timeout: defaultTimeout)
   }