Skip to content

Commit

Permalink
Merge pull request #18 from makeen-project/ALMS-211
Browse files Browse the repository at this point in the history
ALMS-211 GitHub action added for unit test
  • Loading branch information
olegfilimonov authored Jul 4, 2024
2 parents cebf64f + 000aa7f commit 0941d1c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/test-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Unit Tests for Android
on:
workflow_dispatch:
pull_request:
branches: [ main ]
jobs:
test-android:
name: Test Android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'

- name: Run Unit Tests
run: |
./gradlew testDebugUnitTest
- name: Upload test results
uses: actions/upload-artifact@v2
if: always()
with:
name: test-results
path: library/build/reports/tests/testDebugUnitTest/
retention-days: 1
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,32 @@ class LocationCredentialsProviderTest {
}
}

@Test
fun `initializeLocationClient`() {
val expirationTime =
Instant.fromEpochMilliseconds(Instant.now().epochMilliseconds + 10000) // 10 seconds in the future
val mockCredentials =
Credentials.invoke {
expiration = expirationTime
secretKey = "test"
accessKeyId = "test"
sessionToken = "test"
}
every { anyConstructed<CognitoCredentialsProvider>().getCachedCredentials() } returns mockCredentials
every { anyConstructed<EncryptedSharedPreferences>().get(METHOD) } returns ""
every { anyConstructed<EncryptedSharedPreferences>().get(IDENTITY_POOL_ID) } returns TEST_IDENTITY_POOL_ID
every { anyConstructed<EncryptedSharedPreferences>().get(ACCESS_KEY_ID) } returns "test"
every { anyConstructed<EncryptedSharedPreferences>().get(SECRET_KEY) } returns "test"
every { anyConstructed<EncryptedSharedPreferences>().get(SESSION_TOKEN) } returns "test"
every { anyConstructed<EncryptedSharedPreferences>().get(EXPIRATION) } returns "11111"
val provider =
LocationCredentialsProvider(context, TEST_IDENTITY_POOL_ID, AwsRegions.US_EAST_1)
runBlocking {
provider.initializeLocationClient(credentialsProvider)
assertNotNull(provider.getLocationClient())
}
}

@Test
fun `isCredentialsValid returns true when credentials are valid`() {
val expirationTime =
Expand Down

0 comments on commit 0941d1c

Please sign in to comment.