-
Notifications
You must be signed in to change notification settings - Fork 373
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
Conversation
e4d47b3
to
ddd081e
Compare
There was a problem hiding this 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" -> {
ddd081e
to
1416ac6
Compare
There was a problem hiding this 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
e300658
to
0b05b32
Compare
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved
0b05b32
to
1a20b98
Compare
There was a problem hiding this 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:complete! all files reviewed, all discussions resolved
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)