Skip to content

Commit ade1d2a

Browse files
committed
chore(predictions): Simplifying amplifyconfig.json setup
1 parent 685820b commit ade1d2a

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

AmplifyPlugins/Predictions/Tests/PredictionsHostApp/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ amplify-gradle-config.json
1717
amplifytools.xcconfig
1818
.secret-*
1919
**.sample
20-
#amplify-do-not-edit-end
20+
#amplify-do-not-edit-end
21+

AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/AWSPredictionsPluginTestBase.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,16 @@ class AWSPredictionsPluginTestBase: XCTestCase {
1515

1616
// 20 seconds to wait before network timeouts
1717
let networkTimeout = TimeInterval(20)
18-
let amplifyConfigurationFile = "testconfiguration/AWSPredictionsPluginIntegrationTests-amplifyconfiguration"
1918

2019
override func setUp() {
2120
super.setUp()
2221

2322
continueAfterFailure = false
2423

2524
do {
26-
guard let path = Bundle.init(for: type(of: self)).path(
27-
forResource: amplifyConfigurationFile,
28-
ofType: "json"
29-
) else {
30-
fatalError("❌ Could not retrieve configuration file: \(amplifyConfigurationFile)")
31-
}
32-
33-
let url = URL(fileURLWithPath: path)
34-
let data = try Data(contentsOf: url)
35-
let jsonDecoder = JSONDecoder()
36-
let configuration = try jsonDecoder.decode(
37-
AmplifyConfiguration.self,
38-
from: data
39-
)
40-
4125
try Amplify.add(plugin: AWSCognitoAuthPlugin())
4226
try Amplify.add(plugin: AWSPredictionsPlugin())
43-
try Amplify.configure(configuration)
27+
try Amplify.configure()
4428
} catch {
4529
XCTFail(String(describing: error))
4630
return

AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class IdentifyBasicIntegrationTests: AWSPredictionsPluginTestBase {
3333
let electronicsLabel = try XCTUnwrap(
3434
result.labels.first(where: { $0.name == "Electronics" })?.metadata
3535
)
36-
let isConfidentImageContainsElectronics = electronicsLabel.confidence >= 99
3736
XCTAssertNotNil(result)
37+
XCTAssertGreaterThanOrEqual(electronicsLabel.confidence, 99)
3838
}
3939

4040
func testIdentifyModerationLabels() async throws {

AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp.xcodeproj/project.pbxproj

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
03B3827B1594333F4C40DCFC /* amplifyconfiguration.json in Resources */ = {isa = PBXBuildFile; fileRef = 77D412CE71D4C36343815DC9 /* amplifyconfiguration.json */; };
1011
902830062914027000897087 /* PredictionsHostAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902830052914027000897087 /* PredictionsHostAppApp.swift */; };
1112
902830082914027000897087 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902830072914027000897087 /* ContentView.swift */; };
1213
9028300A2914027100897087 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 902830092914027100897087 /* Assets.xcassets */; };
@@ -56,6 +57,7 @@
5657
/* End PBXContainerItemProxy section */
5758

5859
/* Begin PBXFileReference section */
60+
77D412CE71D4C36343815DC9 /* amplifyconfiguration.json */ = {isa = PBXFileReference; explicitFileType = text.json; path = amplifyconfiguration.json; sourceTree = "<group>"; };
5961
902830022914027000897087 /* PredictionsHostApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PredictionsHostApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
6062
902830052914027000897087 /* PredictionsHostAppApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PredictionsHostAppApp.swift; sourceTree = "<group>"; };
6163
902830072914027000897087 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -117,6 +119,14 @@
117119
/* End PBXFrameworksBuildPhase section */
118120

119121
/* Begin PBXGroup section */
122+
7D09EFAF27FE586FBA9A9B2D /* AmplifyConfig */ = {
123+
isa = PBXGroup;
124+
children = (
125+
77D412CE71D4C36343815DC9 /* amplifyconfiguration.json */,
126+
);
127+
name = AmplifyConfig;
128+
sourceTree = "<group>";
129+
};
120130
90282FF92914027000897087 = {
121131
isa = PBXGroup;
122132
children = (
@@ -126,6 +136,7 @@
126136
90283041291402E600897087 /* AWSPredictionsPluginIntegrationTests */,
127137
902830032914027000897087 /* Products */,
128138
9028304A2914042800897087 /* Frameworks */,
139+
7D09EFAF27FE586FBA9A9B2D /* AmplifyConfig */,
129140
);
130141
sourceTree = "<group>";
131142
};
@@ -228,6 +239,7 @@
228239
isa = PBXNativeTarget;
229240
buildConfigurationList = 902830262914027200897087 /* Build configuration list for PBXNativeTarget "PredictionsHostApp" */;
230241
buildPhases = (
242+
56CF7FEF2A0016100073F364 /* ShellScript */,
231243
90282FFE2914027000897087 /* Sources */,
232244
90282FFF2914027000897087 /* Frameworks */,
233245
902830002914027000897087 /* Resources */,
@@ -272,7 +284,6 @@
272284
903555F429141355004B83C2 /* Sources */,
273285
903555F529141355004B83C2 /* Frameworks */,
274286
903555F629141355004B83C2 /* Resources */,
275-
90F5B34529FB404E0036138A /* ShellScript */,
276287
);
277288
buildRules = (
278289
);
@@ -342,6 +353,7 @@
342353
files = (
343354
9028300D2914027100897087 /* Preview Assets.xcassets in Resources */,
344355
9028300A2914027100897087 /* Assets.xcassets in Resources */,
356+
03B3827B1594333F4C40DCFC /* amplifyconfiguration.json in Resources */,
345357
);
346358
runOnlyForDeploymentPostprocessing = 0;
347359
};
@@ -373,7 +385,7 @@
373385
/* End PBXResourcesBuildPhase section */
374386

375387
/* Begin PBXShellScriptBuildPhase section */
376-
90F5B34529FB404E0036138A /* ShellScript */ = {
388+
56CF7FEF2A0016100073F364 /* ShellScript */ = {
377389
isa = PBXShellScriptBuildPhase;
378390
buildActionMask = 2147483647;
379391
files = (
@@ -388,7 +400,8 @@
388400
);
389401
runOnlyForDeploymentPostprocessing = 0;
390402
shellPath = /bin/sh;
391-
shellScript = "TEMP_FILE=$HOME/.aws-amplify/amplify-ios/testconfiguration/.\nDEST_PATH=\"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/testconfiguration/\"\n\nif [[ ! -d $TEMP_FILE ]] ; then\n echo \"${TEMP_FILE} does not exist. Using empty configuration.\"\n exit 0\nfi\n \nif [[ -f $DEST_PATH ]] ; then\n rm $DEST_PATH\nfi\n \ncp -r $TEMP_FILE $DEST_PATH\n";
403+
shellScript = "set -e\n\nSOURCE_DIR=$HOME/.aws-amplify/amplify-ios/testconfiguration\nDESTINATION_DIR=\"$SOURCE_ROOT\"\n\nif [ -d \"$AMPLIFY_CONFIGURATION_PATH\" ]; then\n echo \"Found AMPLIFY_CONFIGURATION_PATH - copying\"\n mkdir -p \"$DESTINATION_DIR\"\n ditto \"$AMPLIFY_CONFIGURATION_PATH\" \"$DESTINATION_DIR\"\n exit 0\nfi\n\nif [ ! -d \"$SOURCE_DIR\" ]; then\n echo \"error: Test configuration directory does not exist: ${SOURCE_DIR}\" && exit 1\nfi\n\nmkdir -p \"$DESTINATION_DIR\"\n\nif [ ! -f \"$SOURCE_DIR/AWSPredictionsPluginIntegrationTests-amplifyconfiguration.json\" ]; then\n echo \"error: Missing AWSPredictionsPluginIntegrationTests-amplifyconfiguration.json from: ${SOURCE_DIR}\" && exit 1\nfi\n\nditto \"$SOURCE_DIR/AWSPredictionsPluginIntegrationTests-amplifyconfiguration.json\" \"$DESTINATION_DIR/amplifyconfiguration.json\"\n";
404+
showEnvVarsInLog = 0;
392405
};
393406
/* End PBXShellScriptBuildPhase section */
394407

0 commit comments

Comments
 (0)