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

Replace Blog with Article #526

Merged
merged 1 commit into from
Jun 4, 2020
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
16 changes: 8 additions & 8 deletions Amplify.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
210922572359693900CEC295 /* BasicAnalyticsEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210922562359693800CEC295 /* BasicAnalyticsEvent.swift */; };
2109225A23596BCD00CEC295 /* AnalyticsCategoryBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2109225923596BCD00CEC295 /* AnalyticsCategoryBehavior.swift */; };
210B3E34245CB73400F43848 /* AuthRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210B3E33245CB73400F43848 /* AuthRule.swift */; };
210B3E36245CB86500F43848 /* Blog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210B3E35245CB86500F43848 /* Blog.swift */; };
210B3E39245CB88D00F43848 /* Blog+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210B3E38245CB88D00F43848 /* Blog+Schema.swift */; };
210DBC122332B3C0009B9E51 /* StorageDownloadFileOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210DBC112332B3C0009B9E51 /* StorageDownloadFileOperation.swift */; };
210DBC142332B3C6009B9E51 /* StorageGetURLOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210DBC132332B3C6009B9E51 /* StorageGetURLOperation.swift */; };
210DBC162332B3CB009B9E51 /* StorageDownloadDataOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210DBC152332B3CB009B9E51 /* StorageDownloadDataOperation.swift */; };
Expand Down Expand Up @@ -71,6 +69,8 @@
21420AA0237222A900FA140C /* AWSAuthorizationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21420A8D237222A900FA140C /* AWSAuthorizationType.swift */; };
2144226C234BDD9B009357F7 /* StorageUploadFileRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2144226B234BDD9B009357F7 /* StorageUploadFileRequest.swift */; };
2144226E234BDE23009357F7 /* StorageUploadFileOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2144226D234BDE23009357F7 /* StorageUploadFileOperation.swift */; };
214F49CD24898E8500DA616C /* Article.swift in Sources */ = {isa = PBXBuildFile; fileRef = 214F49CB24898E8400DA616C /* Article.swift */; };
214F49CE24898E8500DA616C /* Article+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 214F49CC24898E8500DA616C /* Article+Schema.swift */; };
21558E3E237BB4BF0032A5BB /* GraphQLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21558E3D237BB4BF0032A5BB /* GraphQLRequest.swift */; };
21558E40237CB8640032A5BB /* GraphQLError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21558E3F237CB8640032A5BB /* GraphQLError.swift */; };
216879FE23636A0A004A056E /* RepeatingTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 216879FD23636A0A004A056E /* RepeatingTimer.swift */; };
Expand Down Expand Up @@ -635,8 +635,6 @@
210922562359693800CEC295 /* BasicAnalyticsEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicAnalyticsEvent.swift; sourceTree = "<group>"; };
2109225923596BCD00CEC295 /* AnalyticsCategoryBehavior.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsCategoryBehavior.swift; sourceTree = "<group>"; };
210B3E33245CB73400F43848 /* AuthRule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthRule.swift; sourceTree = "<group>"; };
210B3E35245CB86500F43848 /* Blog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Blog.swift; sourceTree = "<group>"; };
210B3E38245CB88D00F43848 /* Blog+Schema.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Blog+Schema.swift"; sourceTree = "<group>"; };
210DBC112332B3C0009B9E51 /* StorageDownloadFileOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageDownloadFileOperation.swift; sourceTree = "<group>"; };
210DBC132332B3C6009B9E51 /* StorageGetURLOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageGetURLOperation.swift; sourceTree = "<group>"; };
210DBC152332B3CB009B9E51 /* StorageDownloadDataOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageDownloadDataOperation.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -706,6 +704,8 @@
21420A8D237222A900FA140C /* AWSAuthorizationType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AWSAuthorizationType.swift; sourceTree = "<group>"; };
2144226B234BDD9B009357F7 /* StorageUploadFileRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageUploadFileRequest.swift; sourceTree = "<group>"; };
2144226D234BDE23009357F7 /* StorageUploadFileOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageUploadFileOperation.swift; sourceTree = "<group>"; };
214F49CB24898E8400DA616C /* Article.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Article.swift; sourceTree = "<group>"; };
214F49CC24898E8500DA616C /* Article+Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Article+Schema.swift"; sourceTree = "<group>"; };
21558E3D237BB4BF0032A5BB /* GraphQLRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GraphQLRequest.swift; sourceTree = "<group>"; };
21558E3F237CB8640032A5BB /* GraphQLError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GraphQLError.swift; sourceTree = "<group>"; };
215F4BCAAB89FA54AA121BDE /* Pods-AmplifyAWSPlugins-AWSPluginsCore-AWSPinpointAnalyticsPlugin.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AmplifyAWSPlugins-AWSPluginsCore-AWSPinpointAnalyticsPlugin.release.xcconfig"; path = "Target Support Files/Pods-AmplifyAWSPlugins-AWSPluginsCore-AWSPinpointAnalyticsPlugin/Pods-AmplifyAWSPlugins-AWSPluginsCore-AWSPinpointAnalyticsPlugin.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2184,8 +2184,8 @@
children = (
B952182F237E21B900F53237 /* schema.graphql */,
FAF512AD23986791001ADF4E /* AmplifyModels.swift */,
210B3E35245CB86500F43848 /* Blog.swift */,
210B3E38245CB88D00F43848 /* Blog+Schema.swift */,
214F49CB24898E8400DA616C /* Article.swift */,
214F49CC24898E8500DA616C /* Article+Schema.swift */,
B9521830237E21B900F53237 /* Comment.swift */,
B952182E237E21B900F53237 /* Comment+Schema.swift */,
FAA2E8BB239FFC7700E420EA /* MockModels.swift */,
Expand Down Expand Up @@ -4395,6 +4395,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
214F49CD24898E8500DA616C /* Article.swift in Sources */,
B9FAA116238799D3009414B4 /* Author.swift in Sources */,
B9521833237E21BA00F53237 /* Comment+Schema.swift in Sources */,
FA176ED7238503C200C5C5F9 /* HubListenerTestUtilities.swift in Sources */,
Expand All @@ -4417,12 +4418,10 @@
FACA36152327FC39000E74F6 /* MessageReporter.swift in Sources */,
FAF512AE23986791001ADF4E /* AmplifyModels.swift in Sources */,
B9FAA11C23879B35009414B4 /* Book.swift in Sources */,
210B3E39245CB88D00F43848 /* Blog+Schema.swift in Sources */,
B9FAA11423878CEA009414B4 /* UserProfile+Schema.swift in Sources */,
FACA361D2327FC84000E74F6 /* MockAPICategoryPlugin.swift in Sources */,
B9FAA11023878C5E009414B4 /* UserProfile.swift in Sources */,
B9AA09F12473CA29000E6FBB /* PostStatus.swift in Sources */,
210B3E36245CB86500F43848 /* Blog.swift in Sources */,
B9FAA12023879BD0009414B4 /* BookAuthor+Schema.swift in Sources */,
21F40A4023A295470074678E /* TestCommonConstants.swift in Sources */,
B9521835237E21BA00F53237 /* Comment.swift in Sources */,
Expand All @@ -4431,6 +4430,7 @@
B9FAA10E23878BF3009414B4 /* UserAccount.swift in Sources */,
21F40A3C23A2952C0074678E /* AuthHelper.swift in Sources */,
B4F3E9FA24314ECC00F23296 /* MockAuthCategoryPlugin.swift in Sources */,
214F49CE24898E8500DA616C /* Article+Schema.swift in Sources */,
FA1846EE23998E44009B9D01 /* MockAPIResponders.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ import XCTest
class GraphQLRequestAuthRuleTests: XCTestCase {

override func setUp() {
ModelRegistry.register(modelType: Blog.self)
ModelRegistry.register(modelType: Article.self)
}

override func tearDown() {
ModelRegistry.reset()
}

func testQueryGraphQLRequest() throws {
let blog = Blog(content: "content", createdAt: .now(), owner: nil, authorNotes: nil)
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelName: blog.modelName, operationType: .query)
let article = Article(content: "content", createdAt: .now(), owner: nil, authorNotes: nil)
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelName: article.modelName, operationType: .query)
documentBuilder.add(decorator: DirectiveNameDecorator(type: .get))
documentBuilder.add(decorator: ModelIdDecorator(id: blog.id))
documentBuilder.add(decorator: ModelIdDecorator(id: article.id))
documentBuilder.add(decorator: ConflictResolutionDecorator())
documentBuilder.add(decorator: AuthRuleDecorator(.query))
let document = documentBuilder.build()
let documentStringValue = """
query GetBlog($id: ID!) {
getBlog(id: $id) {
query GetArticle($id: ID!) {
getArticle(id: $id) {
id
authorNotes
content
Expand All @@ -44,7 +44,7 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
}
"""

let request = GraphQLRequest<MutationSyncResult?>.query(modelName: blog.modelName, byId: blog.id)
let request = GraphQLRequest<MutationSyncResult?>.query(modelName: article.modelName, byId: article.id)

XCTAssertEqual(document.stringValue, request.document)
XCTAssertEqual(documentStringValue, request.document)
Expand All @@ -53,20 +53,20 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
XCTFail("The request doesn't contain variables")
return
}
XCTAssertEqual(variables["id"] as? String, blog.id)
XCTAssertEqual(variables["id"] as? String, article.id)
}

func testCreateMutationGraphQLRequest() throws {
let blog = Blog(content: "content", createdAt: .now(), owner: nil, authorNotes: nil)
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelName: blog.modelName, operationType: .mutation)
let article = Article(content: "content", createdAt: .now(), owner: nil, authorNotes: nil)
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelName: article.modelName, operationType: .mutation)
documentBuilder.add(decorator: DirectiveNameDecorator(type: .create))
documentBuilder.add(decorator: ModelDecorator(model: blog))
documentBuilder.add(decorator: ModelDecorator(model: article))
documentBuilder.add(decorator: ConflictResolutionDecorator())
documentBuilder.add(decorator: AuthRuleDecorator(.mutation))
let document = documentBuilder.build()
let documentStringValue = """
mutation CreateBlog($input: CreateBlogInput!) {
createBlog(input: $input) {
mutation CreateArticle($input: CreateArticleInput!) {
createArticle(input: $input) {
id
authorNotes
content
Expand All @@ -79,7 +79,7 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
}
}
"""
let request = GraphQLRequest<MutationSyncResult>.createMutation(of: blog)
let request = GraphQLRequest<MutationSyncResult>.createMutation(of: article)

XCTAssertEqual(document.stringValue, request.document)
XCTAssertEqual(documentStringValue, request.document)
Expand All @@ -93,21 +93,21 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
XCTFail("The document variables property doesn't contain a valid input")
return
}
XCTAssert(input["content"] as? String == blog.content)
XCTAssert(input["content"] as? String == article.content)
XCTAssertFalse(input.keys.contains("owner"))
}

func testUpdateMutationGraphQLRequest() throws {
let blog = Blog(content: "content", createdAt: .now(), owner: nil, authorNotes: nil)
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelName: blog.modelName, operationType: .mutation)
let article = Article(content: "content", createdAt: .now(), owner: nil, authorNotes: nil)
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelName: article.modelName, operationType: .mutation)
documentBuilder.add(decorator: DirectiveNameDecorator(type: .update))
documentBuilder.add(decorator: ModelDecorator(model: blog))
documentBuilder.add(decorator: ModelDecorator(model: article))
documentBuilder.add(decorator: ConflictResolutionDecorator())
documentBuilder.add(decorator: AuthRuleDecorator(.mutation))
let document = documentBuilder.build()
let documentStringValue = """
mutation UpdateBlog($input: UpdateBlogInput!) {
updateBlog(input: $input) {
mutation UpdateArticle($input: UpdateArticleInput!) {
updateArticle(input: $input) {
id
authorNotes
content
Expand All @@ -120,7 +120,7 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
}
}
"""
let request = GraphQLRequest<MutationSyncResult>.updateMutation(of: blog)
let request = GraphQLRequest<MutationSyncResult>.updateMutation(of: article)

XCTAssertEqual(document.stringValue, request.document)
XCTAssertEqual(documentStringValue, request.document)
Expand All @@ -133,21 +133,21 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
XCTFail("The document variables property doesn't contain a valid input")
return
}
XCTAssert(input["content"] as? String == blog.content)
XCTAssert(input["content"] as? String == article.content)
XCTAssertFalse(input.keys.contains("owner"))
}

func testDeleteMutationGraphQLRequest() throws {
let blog = Blog(content: "content", createdAt: .now(), owner: nil, authorNotes: nil)
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelName: blog.modelName, operationType: .mutation)
let article = Article(content: "content", createdAt: .now(), owner: nil, authorNotes: nil)
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelName: article.modelName, operationType: .mutation)
documentBuilder.add(decorator: DirectiveNameDecorator(type: .delete))
documentBuilder.add(decorator: ModelIdDecorator(id: blog.id))
documentBuilder.add(decorator: ModelIdDecorator(id: article.id))
documentBuilder.add(decorator: ConflictResolutionDecorator())
documentBuilder.add(decorator: AuthRuleDecorator(.mutation))
let document = documentBuilder.build()
let documentStringValue = """
mutation DeleteBlog($input: DeleteBlogInput!) {
deleteBlog(input: $input) {
mutation DeleteArticle($input: DeleteArticleInput!) {
deleteArticle(input: $input) {
id
authorNotes
content
Expand All @@ -161,7 +161,7 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
}
"""

let request = GraphQLRequest<MutationSyncResult>.deleteMutation(modelName: blog.modelName, id: blog.id)
let request = GraphQLRequest<MutationSyncResult>.deleteMutation(modelName: article.modelName, id: article.id)

XCTAssertEqual(document.stringValue, request.document)
XCTAssertEqual(documentStringValue, request.document)
Expand All @@ -174,22 +174,22 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
XCTFail("The document variables property doesn't contain a valid input")
return
}
XCTAssertEqual(input["id"] as? String, blog.id)
XCTAssertEqual(input["id"] as? String, article.id)
XCTAssertFalse(input.keys.contains("owner"))
XCTAssertFalse(input.keys.contains("authorNotes"))
}

func testOnCreateSubscriptionGraphQLRequest() throws {
let modelType = Blog.self as Model.Type
let modelType = Article.self as Model.Type
let ownerId = "111"
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelType: modelType, operationType: .subscription)
documentBuilder.add(decorator: DirectiveNameDecorator(type: .onCreate))
documentBuilder.add(decorator: ConflictResolutionDecorator())
documentBuilder.add(decorator: AuthRuleDecorator(.subscription(.onCreate, ownerId)))
let document = documentBuilder.build()
let documentStringValue = """
subscription OnCreateBlog($owner: String!) {
onCreateBlog(owner: $owner) {
subscription OnCreateArticle($owner: String!) {
onCreateArticle(owner: $owner) {
id
authorNotes
content
Expand Down Expand Up @@ -221,15 +221,15 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
}

func testOnUpdateSubscriptionGraphQLRequest() throws {
let modelType = Blog.self as Model.Type
let modelType = Article.self as Model.Type
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelType: modelType, operationType: .subscription)
documentBuilder.add(decorator: DirectiveNameDecorator(type: .onUpdate))
documentBuilder.add(decorator: ConflictResolutionDecorator())
documentBuilder.add(decorator: AuthRuleDecorator(.subscription(.onUpdate, "111")))
let document = documentBuilder.build()
let documentStringValue = """
subscription OnUpdateBlog {
onUpdateBlog {
subscription OnUpdateArticle {
onUpdateArticle {
id
authorNotes
content
Expand All @@ -253,15 +253,15 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
}

func testOnDeleteSubscriptionGraphQLRequest() throws {
let modelType = Blog.self as Model.Type
let modelType = Article.self as Model.Type
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelType: modelType, operationType: .subscription)
documentBuilder.add(decorator: DirectiveNameDecorator(type: .onDelete))
documentBuilder.add(decorator: ConflictResolutionDecorator())
documentBuilder.add(decorator: AuthRuleDecorator(.subscription(.onDelete, "111")))
let document = documentBuilder.build()
let documentStringValue = """
subscription OnDeleteBlog {
onDeleteBlog {
subscription OnDeleteArticle {
onDeleteArticle {
id
authorNotes
content
Expand All @@ -285,7 +285,7 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
}

func testSyncQueryGraphQLRequest() throws {
let modelType = Blog.self as Model.Type
let modelType = Article.self as Model.Type
let nextToken = "nextToken"
let limit = 100
let lastSync = 123
Expand All @@ -296,8 +296,8 @@ class GraphQLRequestAuthRuleTests: XCTestCase {
documentBuilder.add(decorator: AuthRuleDecorator(.query))
let document = documentBuilder.build()
let documentStringValue = """
query SyncBlogs($lastSync: AWSTimestamp, $limit: Int, $nextToken: String) {
syncBlogs(lastSync: $lastSync, limit: $limit, nextToken: $nextToken) {
query SyncArticles($lastSync: AWSTimestamp, $limit: Int, $nextToken: String) {
syncArticles(lastSync: $lastSync, limit: $limit, nextToken: $nextToken) {
items {
id
authorNotes
Expand Down
Loading