func testLoadingHeroNameQueryWithMissingName()

in ApolloTests/LoadQueryFromStoreTests.swift [46:68]


  func testLoadingHeroNameQueryWithMissingName() throws {
    let initialRecords: RecordSet = [
      "QUERY_ROOT": ["hero": Reference(key: "hero")],
      "hero": ["__typename": "Droid"]
    ]

    withCache(initialRecords: initialRecords) { (cache) in
      store = ApolloStore(cache: cache)

      let query = HeroNameQuery()

      load(query: query) { (result, error) in
        XCTAssertNil(result)

        if case let error as GraphQLResultError = error {
          XCTAssertEqual(error.path, ["hero", "name"])
          XCTAssertMatch(error.underlying, JSONDecodingError.missingValue)
        } else {
          XCTFail("Unexpected error: \(String(describing: error))")
        }
      }
    }
  }