Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reprovision API Integration test backends #250

Merged
merged 12 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Scripts/gcovr
Scripts/jenkins.py
Scripts/ocunit2junit
__pycache__/
awsconfiguration.json
amplifyconfiguration.json
*awsconfiguration.json
lawmicha marked this conversation as resolved.
Show resolved Hide resolved
*amplifyconfiguration.json
credentials-mc.json
84 changes: 67 additions & 17 deletions AmplifyPlugins/API/APICategoryPlugin.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@
<Test
Identifier = "APICategoryPluginConcurrencyTests">
</Test>
<Test
Identifier = "AnyModelIntegrationTests">
</Test>
<Test
Identifier = "AnyModelIntegrationTests/testDeleteAsAnyModel()">
</Test>
<Test
Identifier = "BlogPostCommentGraphQLWithAPIKeyTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,27 @@ import AWSAPICategoryPlugin

@testable import Amplify
@testable import AmplifyTestCommon
@testable import AWSAPICategoryPluginTestCommon

class AnyModelIntegrationTests: XCTestCase {
let networkTimeout: TimeInterval = 180.0

override func setUp() {
Amplify.reset()
Amplify.Logging.logLevel = .verbose
ModelRegistry.register(modelType: AmplifyTestCommon.PostNoSync.self)
ModelRegistry.register(modelType: AmplifyTestCommon.CommentNoSync.self)

let apiConfig = APICategoryConfiguration(plugins: [
"awsAPIPlugin": [
GraphQLModelBasedTests.modelBasedGraphQLWithAPIKey: [
"endpoint": "https://xxx.appsync-api.us-west-2.amazonaws.com/graphql",
"region": "us-west-2",
"authorizationType": "API_KEY",
"apiKey": "xxxx",
"endpointType": "GraphQL"
]
]
])

let amplifyConfig = AmplifyConfiguration(api: apiConfig)

let plugin = AWSAPIPlugin(modelRegistration: PostCommentModelRegistration())

do {
try Amplify.add(plugin: AWSAPIPlugin())
try Amplify.add(plugin: plugin)

let amplifyConfig = try TestConfigHelper.retrieveAmplifyConfiguration(
forResource: GraphQLModelBasedTests.amplifyConfiguration)
try Amplify.configure(amplifyConfig)

ModelRegistry.register(modelType: Comment.self)
ModelRegistry.register(modelType: Post.self)

} catch {
XCTFail("Error during setup: \(error)")
}
Expand All @@ -47,8 +42,10 @@ class AnyModelIntegrationTests: XCTestCase {
}

func testCreateAsAnyModel() throws {
let originalPost = PostNoSync(title: "Post title",
content: "Original post content as of \(Date())")

let originalPost = Post(title: "Post title",
content: "Original post content as of \(Date())",
createdAt: Date())
let anyPost = try originalPost.eraseToAnyModel()

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

func testUpdateAsAnyModel() throws {
let originalPost = PostNoSync(title: "Post title",
content: "Original post content as of \(Date())")
let originalPost = Post(title: "Post title",
content: "Original post content as of \(Date())",
createdAt: Date())
let originalAnyPost = try originalPost.eraseToAnyModel()

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

func testDeleteAsAnyModel() throws {
let originalPost = PostNoSync(title: "Post title",
content: "Original post content as of \(Date())")
let originalPost = Post(title: "Post title",
content: "Original post content as of \(Date())",
createdAt: Date())
let originalAnyPost = try originalPost.eraseToAnyModel()

let createCallbackInvoked = expectation(description: "Create callback invoked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BlogPostCommentGraphQLWithAPIKeyTests: XCTestCase {
"authorizationType": "API_KEY",
"apiKey": "da2-invalidAPIKey",
"endpointType": "GraphQL"
],
]
]
])

Expand Down
Loading