Skip to content

Commit 876b3e9

Browse files
committed
chore(auth): Ensure AWSAuthBaseTest subclasses setup fail if initializeAmplify fails
1 parent cb4ec79 commit 876b3e9

File tree

12 files changed

+32
-62
lines changed

12 files changed

+32
-62
lines changed

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AWSAuthBaseTest.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,11 @@ class AWSAuthBaseTest: XCTestCase {
1818

1919
let amplifyConfigurationFile = "testconfiguration/AWSCognitoAuthPluginIntegrationTests-amplifyconfiguration"
2020

21-
func initializeAmplifyWithError() throws {
21+
func initializeAmplify() throws {
2222
let configuration = try TestConfigHelper.retrieveAmplifyConfiguration(
2323
forResource: amplifyConfigurationFile)
2424
let authPlugin = AWSCognitoAuthPlugin()
2525
try Amplify.add(plugin: authPlugin)
2626
try Amplify.configure(configuration)
2727
}
28-
29-
func initializeAmplify() {
30-
do {
31-
try initializeAmplifyWithError()
32-
print("Amplify configured with auth plugin")
33-
} catch {
34-
print(error)
35-
XCTFail("Failed to initialize Amplify with \(error)")
36-
}
37-
}
3828
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthDeleteUserTests/AuthDeleteUserTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ import AmplifyTestCommon
1414

1515
class AuthDeleteUserTests: AWSAuthBaseTest {
1616

17-
override func setUp() {
18-
super.setUp()
19-
initializeAmplify()
17+
override func setUpWithError() throws {
18+
try initializeAmplify()
2019
}
2120

22-
override func tearDown() {
23-
super.tearDown()
21+
override func tearDownWithError() throws {
2422
Amplify.reset()
2523
sleep(2)
2624
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthDeviceTests/AuthDeviceOperationTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ import AWSMobileClientXCF
1717

1818
class AuthDeviceOperationTests: AWSAuthBaseTest {
1919

20-
override func setUp() {
21-
super.setUp()
22-
initializeAmplify()
20+
override func setUpWithError() throws {
21+
try initializeAmplify()
2322
}
2423

25-
override func tearDown() {
26-
super.tearDown()
24+
override func tearDownWithError() throws {
2725
Amplify.reset()
2826
sleep(2)
2927
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthSessionTests/SignedInAuthSessionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import AmplifyTestCommon
1515
class SignedInAuthSessionTests: AWSAuthBaseTest {
1616

1717
override func setUpWithError() throws {
18-
try initializeAmplifyWithError()
18+
try initializeAmplify()
1919
AuthSessionHelper.clearKeychain()
2020
}
2121

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthSessionTests/SignedOutAuthSessionTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ import AWSPluginsCore
1212

1313
class SignedOutAuthSessionTests: AWSAuthBaseTest {
1414

15-
override func setUp() {
16-
super.setUp()
17-
initializeAmplify()
15+
override func setUpWithError() throws {
16+
try initializeAmplify()
1817
}
1918

20-
override func tearDown() {
21-
super.tearDown()
19+
override func tearDownWithError() throws {
2220
Amplify.reset()
2321
sleep(2)
2422
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthSignInTests/AuthUsernamePasswordSignInTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ import AmplifyTestCommon
1212

1313
class AuthUsernamePasswordSignInTests: AWSAuthBaseTest {
1414

15-
override func setUp() {
16-
super.setUp()
17-
initializeAmplify()
15+
override func setUpWithError() throws {
16+
try initializeAmplify()
1817
}
1918

20-
override func tearDown() {
21-
super.tearDown()
19+
override func tearDownWithError() throws {
2220
Amplify.reset()
2321
sleep(2)
2422
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthSignOutTests/AuthSignOutTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ import AmplifyTestCommon
1414

1515
class AuthSignedOutTests: AWSAuthBaseTest {
1616

17-
override func setUp() {
18-
super.setUp()
19-
initializeAmplify()
17+
override func setUpWithError() throws {
18+
try initializeAmplify()
2019
}
2120

22-
override func tearDown() {
23-
super.tearDown()
21+
override func tearDownWithError() throws {
2422
Amplify.reset()
2523
sleep(2)
2624
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthSignUpTests/AuthConfirmSignUpTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ import AWSCognitoAuthPlugin
1111

1212
class AuthConfirmSignUpTests: AWSAuthBaseTest {
1313

14-
override func setUp() {
15-
super.setUp()
16-
initializeAmplify()
14+
override func setUpWithError() throws {
15+
try initializeAmplify()
1716
}
1817

19-
override func tearDown() {
20-
super.tearDown()
18+
override func tearDownWithError() throws {
2119
Amplify.reset()
2220
sleep(2)
2321
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthSignUpTests/AuthResendSignUpCodeTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ import AWSCognitoAuthPlugin
1111

1212
class AuthResendSignUpCodeTests: AWSAuthBaseTest {
1313

14-
override func setUp() {
15-
super.setUp()
16-
initializeAmplify()
14+
override func setUpWithError() throws {
15+
try initializeAmplify()
1716
}
1817

19-
override func tearDown() {
20-
super.tearDown()
18+
override func tearDownWithError() throws {
2119
Amplify.reset()
2220
sleep(2)
2321
}

AmplifyPlugins/Auth/AWSCognitoAuthPluginIntegrationTests/AuthSignUpTests/AuthSignUpTests.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ import AmplifyTestCommon
1212

1313
class AuthSignUpTests: AWSAuthBaseTest {
1414

15-
override func setUp() {
16-
super.setUp()
17-
initializeAmplify()
15+
override func setUpWithError() throws {
16+
try initializeAmplify()
1817
}
1918

20-
override func tearDown() {
21-
super.tearDown()
19+
override func tearDownWithError() throws {
2220
Amplify.reset()
2321
sleep(2)
2422
}

0 commit comments

Comments
 (0)