Skip to content

Commit 20872a4

Browse files
authored
Reprovision API Integration test backends (#250)
* Set up backend for RESTWithIAMIntegrationTests * Set up backend for GraphQLWithUserPoolIntegrationTests * Add TODO for GraphQLWithIAMIntegrationTests set-up * Moved TodoGraphQLWithAPIKeyTests over to GraphQLWithUserPoolIntegrationTests since they use the same schema * Fixed Functional tests which used PostNoSync/CommentNoSync models * Stopping point before enabling Model based and Sync based tests * Set up backend for GraphQLSyncBasedTests * Set up backend for GraphQLModelBasedTests * minor update to readme * removing config files and adding top level gitignore * updated GraphQL with IAM Readme * update spacing in readme
1 parent ba414a3 commit 20872a4

File tree

22 files changed

+2604
-2878
lines changed

22 files changed

+2604
-2878
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ Scripts/gcovr
4040
Scripts/jenkins.py
4141
Scripts/ocunit2junit
4242
__pycache__/
43-
awsconfiguration.json
44-
amplifyconfiguration.json
43+
*awsconfiguration.json
44+
*amplifyconfiguration.json
4545
credentials-mc.json

AmplifyPlugins/API/APICategoryPlugin.xcodeproj/project.pbxproj

Lines changed: 67 additions & 17 deletions
Large diffs are not rendered by default.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@
2525
<Test
2626
Identifier = "APICategoryPluginConcurrencyTests">
2727
</Test>
28+
<Test
29+
Identifier = "AnyModelIntegrationTests">
30+
</Test>
2831
<Test
2932
Identifier = "AnyModelIntegrationTests/testDeleteAsAnyModel()">
3033
</Test>
34+
<Test
35+
Identifier = "BlogPostCommentGraphQLWithAPIKeyTests">
36+
</Test>
3137
</SkippedTests>
3238
</TestableReference>
3339
</Testables>

AmplifyPlugins/API/AWSAPICategoryPluginFunctionalTests/AWSAPICategoryPluginGetTests.swift

Lines changed: 0 additions & 133 deletions
This file was deleted.

AmplifyPlugins/API/AWSAPICategoryPluginFunctionalTests/AnyModelIntegrationTests.swift

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,27 @@ import AWSAPICategoryPlugin
1111

1212
@testable import Amplify
1313
@testable import AmplifyTestCommon
14+
@testable import AWSAPICategoryPluginTestCommon
1415

1516
class AnyModelIntegrationTests: XCTestCase {
1617
let networkTimeout: TimeInterval = 180.0
1718

1819
override func setUp() {
1920
Amplify.reset()
2021
Amplify.Logging.logLevel = .verbose
21-
ModelRegistry.register(modelType: AmplifyTestCommon.PostNoSync.self)
22-
ModelRegistry.register(modelType: AmplifyTestCommon.CommentNoSync.self)
23-
24-
let apiConfig = APICategoryConfiguration(plugins: [
25-
"awsAPIPlugin": [
26-
GraphQLModelBasedTests.modelBasedGraphQLWithAPIKey: [
27-
"endpoint": "https://xxx.appsync-api.us-west-2.amazonaws.com/graphql",
28-
"region": "us-west-2",
29-
"authorizationType": "API_KEY",
30-
"apiKey": "xxxx",
31-
"endpointType": "GraphQL"
32-
]
33-
]
34-
])
35-
36-
let amplifyConfig = AmplifyConfiguration(api: apiConfig)
22+
23+
let plugin = AWSAPIPlugin(modelRegistration: PostCommentModelRegistration())
24+
3725
do {
38-
try Amplify.add(plugin: AWSAPIPlugin())
26+
try Amplify.add(plugin: plugin)
27+
28+
let amplifyConfig = try TestConfigHelper.retrieveAmplifyConfiguration(
29+
forResource: GraphQLModelBasedTests.amplifyConfiguration)
3930
try Amplify.configure(amplifyConfig)
31+
32+
ModelRegistry.register(modelType: Comment.self)
33+
ModelRegistry.register(modelType: Post.self)
34+
4035
} catch {
4136
XCTFail("Error during setup: \(error)")
4237
}
@@ -47,8 +42,10 @@ class AnyModelIntegrationTests: XCTestCase {
4742
}
4843

4944
func testCreateAsAnyModel() throws {
50-
let originalPost = PostNoSync(title: "Post title",
51-
content: "Original post content as of \(Date())")
45+
46+
let originalPost = Post(title: "Post title",
47+
content: "Original post content as of \(Date())",
48+
createdAt: Date())
5249
let anyPost = try originalPost.eraseToAnyModel()
5350

5451
let callbackInvoked = expectation(description: "Callback invoked")
@@ -98,8 +95,9 @@ class AnyModelIntegrationTests: XCTestCase {
9895
}
9996

10097
func testUpdateAsAnyModel() throws {
101-
let originalPost = PostNoSync(title: "Post title",
102-
content: "Original post content as of \(Date())")
98+
let originalPost = Post(title: "Post title",
99+
content: "Original post content as of \(Date())",
100+
createdAt: Date())
103101
let originalAnyPost = try originalPost.eraseToAnyModel()
104102

105103
let createCallbackInvoked = expectation(description: "Create callback invoked")
@@ -160,8 +158,9 @@ class AnyModelIntegrationTests: XCTestCase {
160158
}
161159

162160
func testDeleteAsAnyModel() throws {
163-
let originalPost = PostNoSync(title: "Post title",
164-
content: "Original post content as of \(Date())")
161+
let originalPost = Post(title: "Post title",
162+
content: "Original post content as of \(Date())",
163+
createdAt: Date())
165164
let originalAnyPost = try originalPost.eraseToAnyModel()
166165

167166
let createCallbackInvoked = expectation(description: "Create callback invoked")

AmplifyPlugins/API/AWSAPICategoryPluginFunctionalTests/BlogPostCommentGraphQLWithAPIKeyTests.swift renamed to AmplifyPlugins/API/AWSAPICategoryPluginFunctionalTests/BlogPostCommentGraphQLWithAPIKey/BlogPostCommentGraphQLWithAPIKeyTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class BlogPostCommentGraphQLWithAPIKeyTests: XCTestCase {
5252
"authorizationType": "API_KEY",
5353
"apiKey": "da2-invalidAPIKey",
5454
"endpointType": "GraphQL"
55-
],
55+
]
5656
]
5757
])
5858

0 commit comments

Comments
 (0)