GRPCStatusTests.swift 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2019, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import GRPC
  17. import XCTest
  18. class GRPCStatusTests: GRPCTestCase {
  19. func testStatusDescriptionWithoutMessage() {
  20. XCTAssertEqual(
  21. "ok (0)",
  22. String(describing: GRPCStatus(code: .ok, message: nil))
  23. )
  24. XCTAssertEqual(
  25. "aborted (10)",
  26. String(describing: GRPCStatus(code: .aborted, message: nil))
  27. )
  28. XCTAssertEqual(
  29. "internal error (13)",
  30. String(describing: GRPCStatus(code: .internalError, message: nil))
  31. )
  32. }
  33. func testStatusDescriptionWithMessage() {
  34. XCTAssertEqual(
  35. "ok (0): OK",
  36. String(describing: GRPCStatus(code: .ok, message: "OK"))
  37. )
  38. XCTAssertEqual(
  39. "resource exhausted (8): a resource was exhausted",
  40. String(describing: GRPCStatus(code: .resourceExhausted, message: "a resource was exhausted"))
  41. )
  42. XCTAssertEqual(
  43. "failed precondition (9): invalid state",
  44. String(describing: GRPCStatus(code: .failedPrecondition, message: "invalid state"))
  45. )
  46. }
  47. }