Skip to content

Commit 78ee0c8

Browse files
authored
chore(api): clean up and enable user pool integ test (#1986)
* chore(api): clean up and enable user pool integ test * Update integ_test.yml
1 parent dac2874 commit 78ee0c8

File tree

4 files changed

+24
-29
lines changed

4 files changed

+24
-29
lines changed

.github/workflows/integ_test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ jobs:
112112
scheme: GraphQLWithIAMIntegrationTests
113113

114114
api-graphqluserpool-integration-test:
115-
if: ${{ false }}
116115
needs: [api-integration-test]
117116
runs-on: macos-latest
118117
environment: IntegrationTest

AmplifyPlugins/API/APICategoryPlugin.xcodeproj/xcshareddata/xcschemes/GraphQLWithUserPoolIntegrationTests.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</BuildableReference>
2525
<SkippedTests>
2626
<Test
27-
Identifier = "GraphQLWithUserPoolIntegrationTests/testSetUpOnce()">
27+
Identifier = "GraphQLAuthDirectiveIntegrationTests">
2828
</Test>
2929
</SkippedTests>
3030
</TestableReference>

AmplifyPlugins/API/AWSAPICategoryPluginIntegrationTests/GraphQL/GraphQLWithUserPoolIntegrationTests/GraphQLWithUserPoolIntegrationTests.swift

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ class GraphQLWithUserPoolIntegrationTests: XCTestCase {
169169
let completeInvoked = expectation(description: "request completed")
170170
let uuid = UUID().uuidString
171171

172-
// create a Todo mutation with a missing/invalid "description" variable value
172+
// create a Todo mutation with a missing/invalid "name" variable value
173173
let request = GraphQLRequest(document: CreateTodoMutation.document,
174174
variables: CreateTodoMutation.variables(id: uuid,
175-
name: "",
175+
name: nil,
176176
description: nil),
177177
responseType: AWSAPICategoryPluginTestCommon.Todo?.self,
178178
decodePath: CreateTodoMutation.decodePath)
@@ -184,17 +184,13 @@ class GraphQLWithUserPoolIntegrationTests: XCTestCase {
184184
return
185185
}
186186

187-
guard case let .transformationError(rawResponse, error) = graphQLResponseError else {
188-
XCTFail("Missing transformation error")
187+
guard case let .error(errors) = graphQLResponseError, let firstError = errors.first else {
188+
XCTFail("Missing errors")
189189
return
190190
}
191-
guard case let .operationError(operationErrorDescription, _, operationError) = error else {
192-
XCTFail("Unexpected error type \(error)")
193-
return
194-
}
195-
XCTAssertNotNil(rawResponse)
196-
XCTAssertNotNil(operationError)
197-
XCTAssertEqual(operationErrorDescription, "valueNotFound")
191+
192+
XCTAssertEqual("Variable 'input' has coerced Null value for NonNull type 'String!'",
193+
firstError.message)
198194

199195
completeInvoked.fulfill()
200196
case .failure(let error):
@@ -447,17 +443,18 @@ class GraphQLWithUserPoolIntegrationTests: XCTestCase {
447443
let operation = Amplify.API.query(request: request) { event in
448444
switch event {
449445
case .success(let graphQLResponse):
450-
guard case let .success(data) = graphQLResponse else {
451-
XCTFail("Missing successful response")
452-
return
453-
}
454-
guard let listTodos = data.listTodos else {
455-
XCTFail("Missing listTodos")
456-
return
446+
switch graphQLResponse {
447+
case .success(let data):
448+
guard let listTodos = data.listTodos else {
449+
XCTFail("Missing listTodos")
450+
return
451+
}
452+
XCTAssertTrue(!listTodos.items.isEmpty)
453+
listCompleteInvoked.fulfill()
454+
case .failure(let error):
455+
print("\(error.underlyingError)")
456+
XCTFail("Unexpected .failed event: \(error)")
457457
}
458-
459-
XCTAssertTrue(!listTodos.items.isEmpty)
460-
listCompleteInvoked.fulfill()
461458
case .failure(let error):
462459
XCTFail("Unexpected .failed event: \(error)")
463460
}

AmplifyPlugins/API/AWSAPICategoryPluginTestCommon/Model/Todo.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
import Foundation
99
import Amplify
1010

11-
/// TODO: Replace with AmplifyTestCommon's DataStore's geneated model
12-
/// This model corresponds to the resources created for the Todo graphQL endpoint. As a developer, this is
13-
/// hand-written from the codegen that created the API.swift that depends on AppSync sdk.
1411
struct Todo: Decodable {
1512
let typename: String
1613
let id: String
1714
let name: String
18-
let description: String
15+
let description: String?
1916

2017
enum CodingKeys: String, CodingKey {
2118
case typename = "__typename"
@@ -48,14 +45,16 @@ class CreateTodoMutation {
4845
}\n}
4946
"""
5047

51-
static func variables(id: String? = nil, name: String, description: String? = nil) -> [String: Any] {
48+
static func variables(id: String? = nil, name: String?, description: String? = nil) -> [String: Any] {
5249
var input: [String: Any] = [:]
5350

5451
if let id = id {
5552
input.updateValue(id, forKey: "id")
5653
}
5754

58-
input.updateValue(name, forKey: "name")
55+
if let name = name {
56+
input.updateValue(name, forKey: "name")
57+
}
5958

6059
if let description = description {
6160
input.updateValue(description, forKey: "description")

0 commit comments

Comments
 (0)