Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mockapi test for handling too many devices #5689

Merged
merged 1 commit into from
Jan 19, 2024

Conversation

Pururun
Copy link
Contributor

@Pururun Pururun commented Jan 15, 2024


This change is Reviewable

@Pururun Pururun added the Android Issues related to Android label Jan 15, 2024
@Pururun Pururun requested a review from albin-mullvad January 15, 2024 16:50
Copy link

linear bot commented Jan 15, 2024

@Pururun Pururun force-pushed the automate-device-tests-using-mockapi-droid-587 branch from e4d47b3 to ddd081e Compare January 16, 2024 09:00
Copy link
Collaborator

@albin-mullvad albin-mullvad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4 of 5 files at r1.
Reviewable status: 4 of 5 files reviewed, 1 unresolved discussion (waiting on @Pururun)


android/test/mockapi/src/main/kotlin/net/mullvad/mullvadvpn/test/mockapi/MockApiDispatcher.kt line 58 at r1 (raw file):

            "$DEVICES_URL_PATH/$DUMMY_ID_3",
            "$DEVICES_URL_PATH/$DUMMY_ID_4",
            "$DEVICES_URL_PATH/$DUMMY_ID_5" -> {

Can this bit be made more dynamic so that the test case can control it? I believe the same can be said for handleDeviceListRequest.

Code quote:

            "$DEVICES_URL_PATH/$DUMMY_ID_1",
            "$DEVICES_URL_PATH/$DUMMY_ID_2",
            "$DEVICES_URL_PATH/$DUMMY_ID_3",
            "$DEVICES_URL_PATH/$DUMMY_ID_4",
            "$DEVICES_URL_PATH/$DUMMY_ID_5" -> {

@Pururun Pururun force-pushed the automate-device-tests-using-mockapi-droid-587 branch from ddd081e to 1416ac6 Compare January 17, 2024 21:24
Copy link
Collaborator

@albin-mullvad albin-mullvad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r3, all commit messages.
Reviewable status: 4 of 5 files reviewed, 3 unresolved discussions (waiting on @Pururun)


android/test/mockapi/src/main/kotlin/net/mullvad/mullvadvpn/test/mockapi/MockApiDispatcher.kt line 32 at r3 (raw file):

    var accountExpiry: DateTime? = null
    var devices: MutableMap<String, String> =
        mapOf(DUMMY_ID_1 to DUMMY_DEVICE_NAME_1).toMutableMap()

Might be a good idea to make sure the test case have to explicitly set this in order to make it transparent to the test case writer/reader. I'm aware that this was more or less hard-coded before, so not really a new issue. We ofc don't want too much boiler plate either. My suggestion is to define a default device list that can be easily set in the dispatcher. This pre-defined list can be set like below or using some extension function etc:

apiDispatcher.apply {
    devices = DEFAULT_DEVICES
}

Code quote:

mapOf(DUMMY_ID_1 to DUMMY_DEVICE_NAME_1).toMutableMap()

android/test/mockapi/src/main/kotlin/net/mullvad/mullvadvpn/test/mockapi/MockApiDispatcher.kt line 36 at r3 (raw file):

        get() = devices.size < 5

    var createDevice = DUMMY_ID_2 to DUMMY_DEVICE_NAME_2

I suggest clarifying the name a bit and to skip the default, since that should be up to the test case. This would result in something like this:

val devicePendingToGetCreated: Device? = null

Code quote:

var createDevice = DUMMY_ID_2 to DUMMY_DEVICE_NAME_2

@Pururun Pururun force-pushed the automate-device-tests-using-mockapi-droid-587 branch 2 times, most recently from e300658 to 0b05b32 Compare January 18, 2024 15:22
Copy link
Contributor Author

@Pururun Pururun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 8 files reviewed, 3 unresolved discussions (waiting on @albin-mullvad)


android/test/mockapi/src/main/kotlin/net/mullvad/mullvadvpn/test/mockapi/MockApiDispatcher.kt line 58 at r1 (raw file):

Previously, albin-mullvad wrote…

Can this bit be made more dynamic so that the test case can control it? I believe the same can be said for handleDeviceListRequest.

Done.


android/test/mockapi/src/main/kotlin/net/mullvad/mullvadvpn/test/mockapi/MockApiDispatcher.kt line 32 at r3 (raw file):

Previously, albin-mullvad wrote…

Might be a good idea to make sure the test case have to explicitly set this in order to make it transparent to the test case writer/reader. I'm aware that this was more or less hard-coded before, so not really a new issue. We ofc don't want too much boiler plate either. My suggestion is to define a default device list that can be easily set in the dispatcher. This pre-defined list can be set like below or using some extension function etc:

apiDispatcher.apply {
    devices = DEFAULT_DEVICES
}

Done.


android/test/mockapi/src/main/kotlin/net/mullvad/mullvadvpn/test/mockapi/MockApiDispatcher.kt line 36 at r3 (raw file):

Previously, albin-mullvad wrote…

I suggest clarifying the name a bit and to skip the default, since that should be up to the test case. This would result in something like this:

val devicePendingToGetCreated: Device? = null

Done.

Copy link
Collaborator

@albin-mullvad albin-mullvad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 6 of 6 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@Pururun Pururun force-pushed the automate-device-tests-using-mockapi-droid-587 branch from 0b05b32 to 1a20b98 Compare January 19, 2024 10:31
Copy link
Collaborator

@albin-mullvad albin-mullvad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@Pururun Pururun merged commit c5ad442 into main Jan 19, 2024
16 checks passed
@Pururun Pururun deleted the automate-device-tests-using-mockapi-droid-587 branch January 19, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants