Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
lawmicha committed Oct 29, 2021
1 parent 2090f27 commit 91a20db
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Amplify.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
21C395B3245729EC00597EA2 /* AppSyncErrorType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21C395B2245729EC00597EA2 /* AppSyncErrorType.swift */; };
21D79FDA237617C60057D00D /* SubscriptionEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21D79FD9237617C60057D00D /* SubscriptionEvent.swift */; };
21D79FE32377F4120057D00D /* SubscriptionConnectionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21D79FE22377F4120057D00D /* SubscriptionConnectionState.swift */; };
21DDCDF7272C3D7400D9B297 /* ModelSchemaGraphQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21DDCDF5272C3D6A00D9B297 /* ModelSchemaGraphQLTests.swift */; };
21DDCDF8272C3D8300D9B297 /* AuthRuleExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 762F70A326683EE2001F8252 /* AuthRuleExtensionTests.swift */; };
21F40A3A23A294770074678E /* TestConfigHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21F40A3923A294770074678E /* TestConfigHelper.swift */; };
21F40A4023A295470074678E /* TestCommonConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21F40A3F23A295470074678E /* TestCommonConstants.swift */; };
21FDBB612587D7A30086FCDC /* Blog6.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21FDBB5B2587D7A30086FCDC /* Blog6.swift */; };
Expand Down Expand Up @@ -250,7 +252,6 @@
762167D52615435C0033FCD2 /* Record+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 762167D42615435C0033FCD2 /* Record+Schema.swift */; };
762C978526210F6400798FA3 /* RecordCover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 762C978426210F6400798FA3 /* RecordCover.swift */; };
762C978E26210FF100798FA3 /* RecordCover+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 762C978D26210FF100798FA3 /* RecordCover+Schema.swift */; };
762F70A426683EE2001F8252 /* AuthRuleExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 762F70A326683EE2001F8252 /* AuthRuleExtensionTests.swift */; };
7638895326A7A9AC0061AF0B /* AWSLambdaAuthConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7638895226A7A9AC0061AF0B /* AWSLambdaAuthConfiguration.swift */; };
7678B38426017D5300B4917F /* AppSyncErrorTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7678B38326017D5300B4917F /* AppSyncErrorTypeTests.swift */; };
7678B38526017D5300B4917F /* AppSyncErrorTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7678B38326017D5300B4917F /* AppSyncErrorTypeTests.swift */; };
Expand Down Expand Up @@ -1013,6 +1014,7 @@
21C395B2245729EC00597EA2 /* AppSyncErrorType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSyncErrorType.swift; sourceTree = "<group>"; };
21D79FD9237617C60057D00D /* SubscriptionEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionEvent.swift; sourceTree = "<group>"; };
21D79FE22377F4120057D00D /* SubscriptionConnectionState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionConnectionState.swift; sourceTree = "<group>"; };
21DDCDF5272C3D6A00D9B297 /* ModelSchemaGraphQLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelSchemaGraphQLTests.swift; sourceTree = "<group>"; };
21F40A3923A294770074678E /* TestConfigHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestConfigHelper.swift; sourceTree = "<group>"; };
21F40A3F23A295470074678E /* TestCommonConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestCommonConstants.swift; sourceTree = "<group>"; };
21FDBB5B2587D7A30086FCDC /* Blog6.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Blog6.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1917,6 +1919,7 @@
2129BE2F2394828A006363A1 /* QueryPredicateGraphQLTests.swift */,
D83C515F248964780091548E /* ModelGraphQLTests.swift */,
762F70A326683EE2001F8252 /* AuthRuleExtensionTests.swift */,
21DDCDF5272C3D6A00D9B297 /* ModelSchemaGraphQLTests.swift */,
);
path = Support;
sourceTree = "<group>";
Expand Down Expand Up @@ -4869,6 +4872,7 @@
219A888723EB89C200BBC5F2 /* GraphQLRequestAnyModelWithSyncTests.swift in Sources */,
2183A56423EA4A7F00232880 /* GraphQLGetQueryTests.swift in Sources */,
6B5087C7256638EA000AB673 /* QueryPredicateEvaluateGeneratedDateTests.swift in Sources */,
21DDCDF8272C3D8300D9B297 /* AuthRuleExtensionTests.swift in Sources */,
6BBECD7423ADA9D100C8DFBE /* AmplifyAWSServiceConfigurationTests.swift in Sources */,
6BAF4F38256893B900A811BA /* QueryPredicateEvaluateGenerator.swift in Sources */,
6B9F7C5225267E1500F1F71C /* MockAWSAuthUser.swift in Sources */,
Expand All @@ -4882,6 +4886,7 @@
6B5087C3256630DB000AB673 /* QueryPredicateEvaluateGeneratedIntTests.swift in Sources */,
21AD425B249C0DBE0016FE95 /* AnyModelTests.swift in Sources */,
D83C5160248964780091548E /* ModelGraphQLTests.swift in Sources */,
21DDCDF7272C3D7400D9B297 /* ModelSchemaGraphQLTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -5338,7 +5343,6 @@
FAC23564227A056600424678 /* StorageCategoryClientAPITests.swift in Sources */,
FAAFAF3123904B75002CF932 /* AtomicValue+BoolTests.swift in Sources */,
B9AF547E23F37DF20059E6C4 /* TemporalOperationTests.swift in Sources */,
762F70A426683EE2001F8252 /* AuthRuleExtensionTests.swift in Sources */,
FAD3937D23820D0200463F5E /* DataStoreCategoryConfigurationTests.swift in Sources */,
FA607FE2233D131B00DFEA24 /* AmplifyOperationHubTests.swift in Sources */,
B4944D52251C141200BF0BFE /* JSONValueHolderTest.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import XCTest
@testable import Amplify
@testable import AmplifyTestCommon
@testable import AWSPluginsCore

class ModelSchemaGraphQLTests: XCTestCase {

func testGraphQLNamesForDeprecatedTodo() throws {
let todo = DeprecatedTodo.schema

XCTAssertEqual(todo.graphQLName(queryType: .get), "getDeprecatedTodo")
XCTAssertEqual(todo.graphQLName(queryType: .list), "listDeprecatedTodos")
XCTAssertEqual(todo.graphQLName(queryType: .sync), "syncDeprecatedTodos")

XCTAssertEqual(todo.graphQLName(subscriptionType: .onCreate), "onCreateDeprecatedTodo")
XCTAssertEqual(todo.graphQLName(subscriptionType: .onUpdate), "onUpdateDeprecatedTodo")
XCTAssertEqual(todo.graphQLName(subscriptionType: .onDelete), "onDeleteDeprecatedTodo")

XCTAssertEqual(todo.graphQLName(mutationType: .create), "createDeprecatedTodo")
XCTAssertEqual(todo.graphQLName(mutationType: .update), "updateDeprecatedTodo")
XCTAssertEqual(todo.graphQLName(mutationType: .delete), "deleteDeprecatedTodo")
}

func testGraphQLNameForWishWithPluralName() {
let wish = ModelSchema(name: "Wish",
pluralName: "Wishes")
XCTAssertEqual(wish.graphQLName(queryType: .get), "getWish")
XCTAssertEqual(wish.graphQLName(queryType: .list), "listWishs")
XCTAssertEqual(wish.graphQLName(queryType: .sync), "syncWishes")

XCTAssertEqual(wish.graphQLName(subscriptionType: .onCreate), "onCreateWish")
XCTAssertEqual(wish.graphQLName(subscriptionType: .onUpdate), "onUpdateWish")
XCTAssertEqual(wish.graphQLName(subscriptionType: .onDelete), "onDeleteWish")

XCTAssertEqual(wish.graphQLName(mutationType: .create), "createWish")
XCTAssertEqual(wish.graphQLName(mutationType: .update), "updateWish")
XCTAssertEqual(wish.graphQLName(mutationType: .delete), "deleteWish")
}

func testGraphQLNameForWishWithListPluralName() {
let wish = ModelSchema(name: "Wish",
listPluralName: "Wishes",
syncPluralName: "Wishes")
XCTAssertEqual(wish.graphQLName(queryType: .get), "getWish")
XCTAssertEqual(wish.graphQLName(queryType: .list), "listWishes")
XCTAssertEqual(wish.graphQLName(queryType: .sync), "syncWishes")

XCTAssertEqual(wish.graphQLName(subscriptionType: .onCreate), "onCreateWish")
XCTAssertEqual(wish.graphQLName(subscriptionType: .onUpdate), "onUpdateWish")
XCTAssertEqual(wish.graphQLName(subscriptionType: .onDelete), "onDeleteWish")

XCTAssertEqual(wish.graphQLName(mutationType: .create), "createWish")
XCTAssertEqual(wish.graphQLName(mutationType: .update), "updateWish")
XCTAssertEqual(wish.graphQLName(mutationType: .delete), "deleteWish")
}
}
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- AWSCore (2.26.2)
- AWSCore (2.26.3)
- CwlCatchException (1.0.2)
- CwlPreconditionTesting (1.1.1):
- CwlCatchException
Expand Down Expand Up @@ -36,7 +36,7 @@ CHECKOUT OPTIONS:
:tag: 1.2.0

SPEC CHECKSUMS:
AWSCore: dd7f74ab3f354aad435f83afdbfac91bcb7d44c2
AWSCore: 7077ecff07ae3b184e65e2fa9855f6da048f9ae7
CwlCatchException: 70a52ae44ea5d46db7bd385f801a94942420cd8c
CwlPreconditionTesting: d33a4e4f285c0b885fddcae5dfedfbb34d4f3961
SwiftFormat: 3b5caa6389b2b9adbc00e133b3ccc8c6e687a6a4
Expand Down

0 comments on commit 91a20db

Please sign in to comment.