From b082ea5d857771c7c999c06d9928faa237fad810 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Wed, 7 Oct 2026 17:40:06 +0800 Subject: [PATCH] =?UTF-8?q?test=E2=9C=85:=20fail=20the=20migrate=20exit-co?= =?UTF-8?q?de=20test=20with=20bad=20SQL=20instead=20of=20a=20missing=20fil?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A missing config/db.sql now falls back to the embedded copy, so it no longer makes the migration fail. Corrupt the on-disk copy, which takes precedence. --- test/e2e-apporder/e2e_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/e2e-apporder/e2e_test.go b/test/e2e-apporder/e2e_test.go index a12a1f9d..d310d02e 100644 --- a/test/e2e-apporder/e2e_test.go +++ b/test/e2e-apporder/e2e_test.go @@ -284,9 +284,12 @@ func TestInstallUninstallReinstall(t *testing.T) { func TestMigrateExitsNonZeroWhenItFails(t *testing.T) { e := newEnv(t) - // The framework's first migration reads config/db.sql. Without it the - // migration fails, which is the cheapest real failure to arrange. - if err := os.Remove(filepath.Join(e.dir, "config", "db.sql")); err != nil { + // The framework's first migration runs config/db.sql, and a copy on disk + // takes precedence over the embedded one. Statements that do not parse + // make that migration fail, which is the cheapest real failure to arrange. + // (Deleting the file no longer does: the embedded copy takes over.) + bad := "THIS IS NOT SQL;\nNEITHER IS THIS;\n" + if err := os.WriteFile(filepath.Join(e.dir, "config", "db.sql"), []byte(bad), 0o600); err != nil { t.Fatal(err) } out, code := e.run("migrate")