Skip to content

Commit 9ed60c7

Browse files
authored
fix(Model): Apply codegen changes test models (#1145)
* fix(Model): API and DataStore integration test for scalars, lists, enums * fix(Model): Apply codegen changes test models * fix(Model): Apply latest code gen changes * fix(Model): Finish API and DataStore scalar integration testing * Update AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginIntegrationTests/TestSupport/TestModelRegistration.swift
1 parent f0cfcfa commit 9ed60c7

File tree

11 files changed

+38
-39
lines changed

11 files changed

+38
-39
lines changed

Amplify.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,8 @@
29592959
762167D42615435C0033FCD2 /* Record+Schema.swift */,
29602960
762C978426210F6400798FA3 /* RecordCover.swift */,
29612961
762C978D26210FF100798FA3 /* RecordCover+Schema.swift */,
2962+
6B7743D625906F7E001469F5 /* Restaurant */,
2963+
21A9051E2616442000EC141D /* Scalar */,
29622964
6B9F7C542526864800F1F71C /* ScenarioATest6Post.swift */,
29632965
6B9F7C532526864800F1F71C /* ScenarioATest6Post+Schema.swift */,
29642966
214F49742486D8A200DA616C /* User.swift */,

AmplifyPlugins/API/AWSAPICategoryPluginFunctionalTests/GraphQLModelBased/GraphQLScalarTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,13 @@ class GraphQLScalarTests: GraphQLTestBase {
185185
XCTAssertNil(emptyModel)
186186
}
187187

188-
// TODO: Update with https://github.com/aws-amplify/amplify-ios/pull/1145
189188
func testListContainerWithNil() {
190189
let container = ListStringContainer(
191190
test: "test",
192191
nullableString: nil,
193192
stringList: ["value1"],
194-
stringNullableList: [], // TODO: test with `nil` with new codegen feature
195-
nullableStringList: ["value1"], // TODO: test with `[nil]`
193+
stringNullableList: nil,
194+
nullableStringList: [nil],
196195
nullableStringNullableList: nil)
197196

198197
let updatedContainer = ListStringContainer(id: container.id,

AmplifyPlugins/DataStore/AWSDataStoreCategoryPluginIntegrationTests/DataStoreScalarTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,14 @@ class DataStoreScalarTests: SyncEngineIntegrationTestBase {
152152
XCTAssertNil(emptyModel)
153153
}
154154

155-
// TODO: Not sure how this was compiling and tested before, should be fixed with
156-
// https://github.com/aws-amplify/amplify-ios/pull/1145
157155
func testListContainerWithNil() throws {
158156
try startAmplifyAndWaitForSync()
159157
let container = ListStringContainer(
160158
test: "test",
161159
nullableString: nil,
162160
stringList: ["value1"],
163-
stringNullableList: [], // TODO: test with `nil` with new codegen feature
164-
nullableStringList: ["value1"], // TODO: test with `[nil]`
161+
stringNullableList: nil,
162+
nullableStringList: [nil],
165163
nullableStringNullableList: nil)
166164

167165
let updatedContainer = ListStringContainer(id: container.id,

AmplifyTestCommon/Models/Scalar/EnumTestModel+Schema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ extension EnumTestModel {
3434
.field(enumTestModel.enumVal, is: .required, ofType: .enum(type: TestEnum.self)),
3535
.field(enumTestModel.nullableEnumVal, is: .optional, ofType: .enum(type: TestEnum.self)),
3636
.field(enumTestModel.enumList, is: .required, ofType: .embeddedCollection(of: TestEnum.self)),
37-
.field(enumTestModel.enumNullableList, is: .required, ofType: .embeddedCollection(of: TestEnum.self)),
38-
.field(enumTestModel.nullableEnumList, is: .optional, ofType: .embeddedCollection(of: TestEnum.self)),
37+
.field(enumTestModel.enumNullableList, is: .optional, ofType: .embeddedCollection(of: TestEnum.self)),
38+
.field(enumTestModel.nullableEnumList, is: .required, ofType: .embeddedCollection(of: TestEnum.self)),
3939
.field(enumTestModel.nullableEnumNullableList, is: .optional, ofType: .embeddedCollection(of: TestEnum.self))
4040
)
4141
}

AmplifyTestCommon/Models/Scalar/EnumTestModel.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ public struct EnumTestModel: Model {
1414
public var enumVal: TestEnum
1515
public var nullableEnumVal: TestEnum?
1616
public var enumList: [TestEnum]
17-
public var enumNullableList: [TestEnum]
18-
public var nullableEnumList: [TestEnum]?
19-
public var nullableEnumNullableList: [TestEnum]?
17+
public var enumNullableList: [TestEnum]?
18+
public var nullableEnumList: [TestEnum?]
19+
public var nullableEnumNullableList: [TestEnum?]?
2020

2121
public init(id: String = UUID().uuidString,
2222
enumVal: TestEnum,
2323
nullableEnumVal: TestEnum? = nil,
2424
enumList: [TestEnum] = [],
25-
enumNullableList: [TestEnum] = [],
26-
nullableEnumList: [TestEnum]? = [],
27-
nullableEnumNullableList: [TestEnum]? = []) {
25+
enumNullableList: [TestEnum]? = nil,
26+
nullableEnumList: [TestEnum?] = [],
27+
nullableEnumNullableList: [TestEnum?]? = nil) {
2828
self.id = id
2929
self.enumVal = enumVal
3030
self.nullableEnumVal = nullableEnumVal

AmplifyTestCommon/Models/Scalar/ListIntContainer+Schema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ extension ListIntContainer {
3434
.field(listIntContainer.test, is: .required, ofType: .int),
3535
.field(listIntContainer.nullableInt, is: .optional, ofType: .int),
3636
.field(listIntContainer.intList, is: .required, ofType: .embeddedCollection(of: Int.self)),
37-
.field(listIntContainer.intNullableList, is: .required, ofType: .embeddedCollection(of: Int.self)),
38-
.field(listIntContainer.nullableIntList, is: .optional, ofType: .embeddedCollection(of: Int.self)),
37+
.field(listIntContainer.intNullableList, is: .optional, ofType: .embeddedCollection(of: Int.self)),
38+
.field(listIntContainer.nullableIntList, is: .required, ofType: .embeddedCollection(of: Int.self)),
3939
.field(listIntContainer.nullableIntNullableList, is: .optional, ofType: .embeddedCollection(of: Int.self))
4040
)
4141
}

AmplifyTestCommon/Models/Scalar/ListIntContainer.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ public struct ListIntContainer: Model {
1414
public var test: Int
1515
public var nullableInt: Int?
1616
public var intList: [Int]
17-
public var intNullableList: [Int]
18-
public var nullableIntList: [Int]?
19-
public var nullableIntNullableList: [Int]?
17+
public var intNullableList: [Int]?
18+
public var nullableIntList: [Int?]
19+
public var nullableIntNullableList: [Int?]?
2020

2121
public init(id: String = UUID().uuidString,
2222
test: Int,
2323
nullableInt: Int? = nil,
2424
intList: [Int] = [],
25-
intNullableList: [Int] = [],
26-
nullableIntList: [Int]? = [],
27-
nullableIntNullableList: [Int]? = []) {
25+
intNullableList: [Int]? = nil,
26+
nullableIntList: [Int?] = [],
27+
nullableIntNullableList: [Int?]? = nil) {
2828
self.id = id
2929
self.test = test
3030
self.nullableInt = nullableInt

AmplifyTestCommon/Models/Scalar/ListStringContainer+Schema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ extension ListStringContainer {
3434
.field(listStringContainer.test, is: .required, ofType: .string),
3535
.field(listStringContainer.nullableString, is: .optional, ofType: .string),
3636
.field(listStringContainer.stringList, is: .required, ofType: .embeddedCollection(of: String.self)),
37-
.field(listStringContainer.stringNullableList, is: .required, ofType: .embeddedCollection(of: String.self)),
38-
.field(listStringContainer.nullableStringList, is: .optional, ofType: .embeddedCollection(of: String.self)),
37+
.field(listStringContainer.stringNullableList, is: .optional, ofType: .embeddedCollection(of: String.self)),
38+
.field(listStringContainer.nullableStringList, is: .required, ofType: .embeddedCollection(of: String.self)),
3939
.field(listStringContainer.nullableStringNullableList, is: .optional, ofType: .embeddedCollection(of: String.self))
4040
)
4141
}

AmplifyTestCommon/Models/Scalar/ListStringContainer.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ public struct ListStringContainer: Model {
1414
public var test: String
1515
public var nullableString: String?
1616
public var stringList: [String]
17-
public var stringNullableList: [String]
18-
public var nullableStringList: [String]?
19-
public var nullableStringNullableList: [String]?
17+
public var stringNullableList: [String]?
18+
public var nullableStringList: [String?]
19+
public var nullableStringNullableList: [String?]?
2020

2121
public init(id: String = UUID().uuidString,
2222
test: String,
2323
nullableString: String? = nil,
2424
stringList: [String] = [],
25-
stringNullableList: [String] = [],
26-
nullableStringList: [String]? = [],
27-
nullableStringNullableList: [String]? = []) {
25+
stringNullableList: [String]? = nil,
26+
nullableStringList: [String?] = [],
27+
nullableStringNullableList: [String?]? = nil) {
2828
self.id = id
2929
self.test = test
3030
self.nullableString = nullableString

AmplifyTestCommon/Models/Scalar/NestedTypeTestModel+Schema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ extension NestedTypeTestModel {
3434
.field(nestedTypeTestModel.nestedVal, is: .required, ofType: .embedded(type: Nested.self)),
3535
.field(nestedTypeTestModel.nullableNestedVal, is: .optional, ofType: .embedded(type: Nested.self)),
3636
.field(nestedTypeTestModel.nestedList, is: .required, ofType: .embeddedCollection(of: Nested.self)),
37-
.field(nestedTypeTestModel.nestedNullableList, is: .required, ofType: .embeddedCollection(of: Nested.self)),
38-
.field(nestedTypeTestModel.nullableNestedList, is: .optional, ofType: .embeddedCollection(of: Nested.self)),
37+
.field(nestedTypeTestModel.nestedNullableList, is: .optional, ofType: .embeddedCollection(of: Nested.self)),
38+
.field(nestedTypeTestModel.nullableNestedList, is: .required, ofType: .embeddedCollection(of: Nested.self)),
3939
.field(nestedTypeTestModel.nullableNestedNullableList, is: .optional, ofType: .embeddedCollection(of: Nested.self))
4040
)
4141
}

0 commit comments

Comments
 (0)