test(android): name the uninstall failure for what it says, not why

This commit is contained in:
pj committed 2026-08-16 00:07:58 +05:30
1 parent 87aa7d9284
commit ea952378fe
1 file changed
+9 -9
+9 -9
View File
@@ -475,18 +475,18 @@ func adbCalls(t *testing.T, log string) []string {
} }
const ( const (
uninstallRefused = `"uninstall "*) echo "Failure [DELETE_FAILED_INTERNAL_ERROR]"; exit 1;;` uninstallFails = `"uninstall "*) echo "Failure [DELETE_FAILED_INTERNAL_ERROR]"; exit 1;;`
stillInstalled = `"shell pm path "*) echo "package:/data/app/app.example-1/base.apk";;` stillInstalled = `"shell pm path "*) echo "package:/data/app/app.example-1/base.apk";;`
notInstalled = `"shell pm path "*) exit 1;;` notInstalled = `"shell pm path "*) exit 1;;`
installedSuccessfully = `"install "*) echo "Success";;` installSucceeds = `"install "*) echo "Success";;`
) )
func TestReinstallApp_RefusedUninstallClearsTheDataItLeftBehind(t *testing.T) { func TestReinstallApp_RefusedUninstallClearsTheDataItLeftBehind(t *testing.T) {
log := scriptedAdb(t, strings.Join([]string{ log := scriptedAdb(t, strings.Join([]string{
uninstallRefused, uninstallFails,
stillInstalled, stillInstalled,
`"shell pm clear "*) echo "Success";;`, `"shell pm clear "*) echo "Success";;`,
installedSuccessfully, installSucceeds,
}, "\n")) }, "\n"))
output := &strings.Builder{} output := &strings.Builder{}
@@ -510,10 +510,10 @@ func TestReinstallApp_RefusedUninstallClearsTheDataItLeftBehind(t *testing.T) {
func TestReinstallApp_RefusedUninstallThatCannotBeClearedIsFatal(t *testing.T) { func TestReinstallApp_RefusedUninstallThatCannotBeClearedIsFatal(t *testing.T) {
log := scriptedAdb(t, strings.Join([]string{ log := scriptedAdb(t, strings.Join([]string{
uninstallRefused, uninstallFails,
stillInstalled, stillInstalled,
`"shell pm clear "*) echo "Failed"; exit 1;;`, `"shell pm clear "*) echo "Failed"; exit 1;;`,
installedSuccessfully, installSucceeds,
}, "\n")) }, "\n"))
err := ReinstallApp(t.Context(), "", "app.example", "/tmp/app.apk", &strings.Builder{}) err := ReinstallApp(t.Context(), "", "app.example", "/tmp/app.apk", &strings.Builder{})
@@ -533,9 +533,9 @@ func TestReinstallApp_RefusedUninstallThatCannotBeClearedIsFatal(t *testing.T) {
func TestReinstallApp_UninstallFailureWithNothingInstalledIsQuiet(t *testing.T) { func TestReinstallApp_UninstallFailureWithNothingInstalledIsQuiet(t *testing.T) {
log := scriptedAdb(t, strings.Join([]string{ log := scriptedAdb(t, strings.Join([]string{
uninstallRefused, uninstallFails,
notInstalled, notInstalled,
installedSuccessfully, installSucceeds,
}, "\n")) }, "\n"))
output := &strings.Builder{} output := &strings.Builder{}
@@ -560,7 +560,7 @@ func TestReinstallApp_SuccessfulUninstallNeedsNoFallback(t *testing.T) {
`"uninstall "*) echo "Success";;`, `"uninstall "*) echo "Success";;`,
stillInstalled, stillInstalled,
`"shell pm clear "*) echo "Success";;`, `"shell pm clear "*) echo "Success";;`,
installedSuccessfully, installSucceeds,
}, "\n")) }, "\n"))
if err := ReinstallApp(t.Context(), "", "app.example", "/tmp/app.apk", &strings.Builder{}); err != nil { if err := ReinstallApp(t.Context(), "", "app.example", "/tmp/app.apk", &strings.Builder{}); err != nil {