From 9914373d450c0f81cf2ebd87ce8c66a214c2259f Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Sat, 22 Aug 2026 11:40:38 +0800 Subject: [PATCH] =?UTF-8?q?test=F0=9F=A7=AA:=20run=20the=20assertion=20thr?= =?UTF-8?q?ough=20the=20function=20it=20is=20about?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review caught that this reissued getByRoleName's query instead of calling it, so it passed whether or not the production line still said what it was supposed to — a test named for a change it did not touch. It calls getByRoleName now, and restoring the hand-written clause fails it for exactly the reason this PR exists: with the marker non-null, "deleted_at is null" matches nothing and the query returns an empty list. --- app/admin/service/sys_menu_softdelete_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/admin/service/sys_menu_softdelete_test.go b/app/admin/service/sys_menu_softdelete_test.go index d4a7cd6f..867d5c16 100644 --- a/app/admin/service/sys_menu_softdelete_test.go +++ b/app/admin/service/sys_menu_softdelete_test.go @@ -35,9 +35,15 @@ func TestSoftDeletedMenusAreNotReturned(t *testing.T) { t.Fatalf("delete: %v", err) } - var got []models.SysMenu - if err := db.Where("menu_type in ('M','C')").Order("sort").Find(&got).Error; err != nil { - t.Fatalf("find: %v", err) + // Through getByRoleName rather than a copy of its query: a test that + // reissues the statement passes whether or not the production line still + // says what it is supposed to, which is what the first version of this + // test did. + e := &SysMenu{} + e.Orm = db + got, err := e.getByRoleName("admin") + if err != nil { + t.Fatalf("getByRoleName: %v", err) } if len(got) != 1 {