-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[UPDATE/OPTIMIZE] Add tests for PlantDetailViewModel and adjust add() #349
base: main
Are you sure you want to change the base?
[UPDATE/OPTIMIZE] Add tests for PlantDetailViewModel and adjust add() #349
Conversation
629ce43
to
4272e92
Compare
4272e92
to
85d03c1
Compare
app/src/main/java/com/google/samples/apps/sunflower/viewmodels/PlantDetailViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/google/samples/apps/sunflower/viewmodels/PlantDetailViewModel.kt
Show resolved
Hide resolved
Hmmm... I'm getting an error when I try to run this?
|
@nic0lette 😢 but it's really strange, I try this I tried running, however, the output is failed:
|
@XinyueZ Yeah =( I tried with a fresh copy of the code in a separate directory and applied this PR. When I run all of the tests, it works great! Thank you! I kept digging, and if I only run |
The PR is for the enhancement on the unit-tests of
PlantDetailViewModel
since we added thecoroutines
feature there.TEST update:
shouldAddPlantToGarden(): Happy-Path to add one plant.
shouldCancelAddingPlantToGarden(): Cancel adding of one plant with calling
cancel
on the return handler ofaddPlantToGarden
.shouldCancelAddingPlantToGardenByViewModel(): Cancel adding of one plant with calling
cancel
on theview-model
.Based on this TEST update:
Refactoring,
addPlantToGarden()
which can returnJob
handler regard of the reason that the client codes cancancel
adding action separately and flexibly instead only callingcancel
ofview-model
.Whether you agree?
@tiembo @nic0lette @objcode