From 76196a28973b204cbbd4ba7a079883803d3c903b Mon Sep 17 00:00:00 2001 From: Cao Yuhang Date: Mon, 13 Jul 2026 17:08:21 +0000 Subject: [PATCH] operations: fix core/du test with missing cache dir TestRcDu relied on the default cache directory already existing. In clean or container environments diskusage.New returned ENOENT, which the test ignored before type asserting a nil result. Use a temporary directory and require a successful response before checking the disk usage values. --- fs/operations/rc_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/operations/rc_test.go b/fs/operations/rc_test.go index 04357fb72..4877806dc 100644 --- a/fs/operations/rc_test.go +++ b/fs/operations/rc_test.go @@ -650,13 +650,16 @@ func TestRcCommand(t *testing.T) { func TestRcDu(t *testing.T) { ctx := context.Background() _, call := rcNewRun(t, "core/du") - in := rc.Params{} + dir := t.TempDir() + in := rc.Params{"dir": dir} out, err := call.Fn(ctx, in) if err == diskusage.ErrUnsupported { t.Skip(err) } - assert.NotEqual(t, "", out["dir"]) - info := out["info"].(diskusage.Info) + require.NoError(t, err) + assert.Equal(t, dir, out["dir"]) + info, ok := out["info"].(diskusage.Info) + require.True(t, ok) assert.True(t, info.Total != 0) assert.True(t, info.Total > info.Free) assert.True(t, info.Total > info.Available)