From 37f478fb8e4b06cb02463f444496e72e5906355e Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Fri, 10 Apr 2026 16:03:21 +0400 Subject: [PATCH 1/3] Use shoulda --- go.mod | 7 ++++++- internal/caches/local/disk_test.go | 9 +++++---- internal/caches/local/local_test.go | 6 ++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index e2239b2..bc3d712 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/AlekSi/hardcache -go 1.25 +go 1.26 + +toolchain go1.26.2 // https://go.dev/doc/godebug#go-120 // https://pkg.go.dev/archive/tar#Reader.Next @@ -10,8 +12,11 @@ godebug ( zipinsecurepath=0 ) +replace github.com/AlekSi/shoulda => ../shoulda + require ( github.com/AlekSi/lazyerrors v0.5.0 + github.com/AlekSi/shoulda v0.0.0-00010101000000-000000000000 github.com/alecthomas/kong v1.14.0 github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b github.com/stretchr/testify v1.11.1 diff --git a/internal/caches/local/disk_test.go b/internal/caches/local/disk_test.go index 4ea15ff..960509c 100644 --- a/internal/caches/local/disk_test.go +++ b/internal/caches/local/disk_test.go @@ -4,7 +4,8 @@ import ( "os/exec" "testing" - "github.com/stretchr/testify/assert" + "github.com/AlekSi/shoulda" + "github.com/AlekSi/shoulda/cmp" "github.com/stretchr/testify/require" ) @@ -18,7 +19,7 @@ func TestDiskInfo(t *testing.T) { t.Logf("\n total: %dM, free: %dM", total/1024/1024, free/1024/1024) - assert.Positive(t, total) - assert.Positive(t, free) - assert.Greater(t, total, free) + shoulda.ReturnTrue(t, total, cmp.Greater, 0) + shoulda.ReturnTrue(t, free, cmp.Greater, 0) + shoulda.ReturnTrue(t, total, cmp.Greater, free) } diff --git a/internal/caches/local/local_test.go b/internal/caches/local/local_test.go index 071febf..1d549ce 100644 --- a/internal/caches/local/local_test.go +++ b/internal/caches/local/local_test.go @@ -9,6 +9,8 @@ import ( "testing" "time" + "github.com/AlekSi/shoulda" + "github.com/AlekSi/shoulda/cmp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -116,8 +118,8 @@ func TestTrimNoop(t *testing.T) { require.NoError(t, err) before, freed := c.TrimForce() - assert.EqualValues(t, -1, before) - assert.EqualValues(t, 0, freed) + shoulda.ReturnTrue(t, before, cmp.Equal, -1) + shoulda.ReturnTrue(t, freed, cmp.Equal, 0) } func TestTrimCutoffNone(t *testing.T) { From 10f64c8c2ef172d9c9148242412bb0ef0bf30972 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Tue, 12 May 2026 22:43:49 +0400 Subject: [PATCH 2/3] Bump --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 5ba9b17..616c6c3 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/AlekSi/hardcache -go 1.26 +go 1.25.0 toolchain go1.26.3 @@ -14,7 +14,7 @@ godebug ( require ( github.com/AlekSi/lazyerrors v0.6.0 - github.com/AlekSi/shoulda v0.0.0-20260512161828-3f1a6205d664 + github.com/AlekSi/shoulda v0.0.0-20260512184202-90296728414d github.com/alecthomas/kong v1.15.0 github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b github.com/stretchr/testify v1.11.1 diff --git a/go.sum b/go.sum index 38e5e37..b00004a 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/AlekSi/lazyerrors v0.6.0 h1:TX4iCP7N+YOuOmUl6Gv5OQ7brhPzPPrSsEAm+at+avk= github.com/AlekSi/lazyerrors v0.6.0/go.mod h1:TresBdOmCoC169IDo09YbrYUDXiqRwlLpInBeS1qD2g= -github.com/AlekSi/shoulda v0.0.0-20260512161828-3f1a6205d664 h1:+9lHGBM7WMgnomITmZL892SI07D3vnCegF1VouXSydw= -github.com/AlekSi/shoulda v0.0.0-20260512161828-3f1a6205d664/go.mod h1:KWJR3KfSauCVWX2/MEoofulvkLMTWN2ew8SfaHAdohw= +github.com/AlekSi/shoulda v0.0.0-20260512184202-90296728414d h1:+1oFTJXeqDo0mKvIgFSbgG1WIz5t5nl14dX0EylSVK0= +github.com/AlekSi/shoulda v0.0.0-20260512184202-90296728414d/go.mod h1:QH+MbmZ0XGLxMGQqQLpWokX+oKxrvJq8QHl9UDwPiHk= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/kong v1.15.0 h1:BVJstKbpO73zKpmIu+m/aLRrNmWwxXPIGTNin9VmLVI= From fad38bb59dab478a439efd475edb6bccb866a8be Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Wed, 13 May 2026 06:57:22 +0400 Subject: [PATCH 3/3] WIP --- internal/caches/local/disk_test.go | 7 +++---- internal/caches/local/local_test.go | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/internal/caches/local/disk_test.go b/internal/caches/local/disk_test.go index 960509c..fa8a9eb 100644 --- a/internal/caches/local/disk_test.go +++ b/internal/caches/local/disk_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/AlekSi/shoulda" - "github.com/AlekSi/shoulda/cmp" "github.com/stretchr/testify/require" ) @@ -19,7 +18,7 @@ func TestDiskInfo(t *testing.T) { t.Logf("\n total: %dM, free: %dM", total/1024/1024, free/1024/1024) - shoulda.ReturnTrue(t, total, cmp.Greater, 0) - shoulda.ReturnTrue(t, free, cmp.Greater, 0) - shoulda.ReturnTrue(t, total, cmp.Greater, free) + shoulda.BeGreater(t, total, 0) + shoulda.BeGreater(t, free, 0) + shoulda.BeGreater(t, total, free) } diff --git a/internal/caches/local/local_test.go b/internal/caches/local/local_test.go index 1d549ce..7d048bf 100644 --- a/internal/caches/local/local_test.go +++ b/internal/caches/local/local_test.go @@ -10,7 +10,6 @@ import ( "time" "github.com/AlekSi/shoulda" - "github.com/AlekSi/shoulda/cmp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -118,8 +117,8 @@ func TestTrimNoop(t *testing.T) { require.NoError(t, err) before, freed := c.TrimForce() - shoulda.ReturnTrue(t, before, cmp.Equal, -1) - shoulda.ReturnTrue(t, freed, cmp.Equal, 0) + shoulda.BeEqual(t, before, -1) + shoulda.BeEqual(t, freed, 0) } func TestTrimCutoffNone(t *testing.T) {