Skip to content

Commit c192b24

Browse files
committed
-testify +tool
1 parent d044218 commit c192b24

File tree

8 files changed

+326
-51
lines changed

8 files changed

+326
-51
lines changed

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"name": "Launch Package",
10+
"type": "go",
11+
"request": "launch",
12+
"mode": "auto",
13+
"program": "${fileDirname}",
14+
"args": ["${workspaceFolder}/go.mod"]
15+
}
16+
]
17+
}

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ all:
22
$(error please pick a target)
33

44
lint:
5-
staticcheck ./...
6-
gosec ./...
7-
govulncheck ./...
5+
go tool staticcheck ./...
6+
go tool gosec ./...
7+
go tool govulncheck ./...
88

99
test: lint
1010
go test -v
1111

1212
install-tools:
13-
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v2.22.2
13+
go install github.com/caarlos0/svu@latest
14+
go install github.com/securego/gosec/v2/cmd/gosec@latest
1415
go install golang.org/x/vuln/cmd/govulncheck@latest
1516
go install honnef.co/go/tools/cmd/staticcheck@latest
16-
go install github.com/caarlos0/svu@latest
17-
@echo "Done. Don't forget to add '\$$(go env GOPATH)/bin' to your '\$$PATH'"
17+
@echo "Tools installed from go.mod tool directive"
1818

1919
ci: install-tools test
2020

2121
release-patch:
22-
git tag $(shell svu patch)
22+
git tag $(shell go tool svu patch)
2323
git push --tags
2424

2525
release-minor:
26-
git tag $(shell svu minor)
26+
git tag $(shell go tool svu minor)
2727
git push --tags

cache_test.go

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ import (
44
"path"
55
"strings"
66
"testing"
7-
8-
"github.com/stretchr/testify/require"
97
)
108

119
func Test_cacheFile(t *testing.T) {
1210
fileName, err := cacheFileName()
13-
require.NoError(t, err)
14-
require.True(t, strings.HasSuffix(fileName, ".local/cache/expmod/cache.gob"))
11+
if err != nil {
12+
t.Fatalf("cacheFileName: %v", err)
13+
}
14+
if !strings.HasSuffix(fileName, ".local/cache/expmod/cache.gob") {
15+
t.Fatalf("expected filename to end with .local/cache/expmod/cache.gob, got %q", fileName)
16+
}
1517

1618
tmpCache := "/tmp/expmod-cached.gob"
1719
t.Setenv(cacheEnvKey, tmpCache)
1820
fileName, err = cacheFileName()
19-
require.NoError(t, err)
20-
require.Equal(t, tmpCache, fileName)
21+
if err != nil {
22+
t.Fatalf("cacheFileName: %v", err)
23+
}
24+
if fileName != tmpCache {
25+
t.Fatalf("expected %q, got %q", tmpCache, fileName)
26+
}
2127
}
2228

2329
func TestCache(t *testing.T) {
@@ -30,10 +36,23 @@ func TestCache(t *testing.T) {
3036
"b": "c",
3137
}
3238
err := saveCache(cache)
33-
require.NoError(t, err, "save")
39+
if err != nil {
40+
t.Fatalf("save: %v", err)
41+
}
3442

3543
loaded, err := loadCache()
36-
require.NoError(t, err, "load")
37-
require.Equal(t, cache, loaded)
44+
if err != nil {
45+
t.Fatalf("load: %v", err)
46+
}
47+
for k, v := range cache {
48+
if loaded[k] != v {
49+
t.Fatalf("cache mismatch for key %q: expected %q, got %q", k, v, loaded[k])
50+
}
51+
}
52+
for k, v := range loaded {
53+
if cache[k] != v {
54+
t.Fatalf("loaded mismatch for key %q: expected %q, got %q", k, v, cache[k])
55+
}
56+
}
3857

3958
}

go.mod

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,67 @@ module github.com/tebeka/expmod
33
go 1.24
44

55
require (
6-
github.com/stretchr/testify v1.10.0
7-
golang.org/x/mod v0.24.0
8-
golang.org/x/net v0.37.0
6+
golang.org/x/mod v0.27.0
7+
golang.org/x/net v0.43.0
98
)
109

1110
require (
12-
github.com/davecgh/go-spew v1.1.1 // indirect
13-
github.com/pmezard/go-difflib v1.0.0 // indirect
11+
cloud.google.com/go v0.121.2 // indirect
12+
cloud.google.com/go/ai v0.12.1 // indirect
13+
cloud.google.com/go/auth v0.16.2 // indirect
14+
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
15+
cloud.google.com/go/compute/metadata v0.7.0 // indirect
16+
cloud.google.com/go/longrunning v0.6.7 // indirect
17+
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
18+
github.com/Masterminds/semver v1.5.0 // indirect
19+
github.com/alecthomas/kingpin v2.2.6+incompatible // indirect
20+
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
21+
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 // indirect
22+
github.com/caarlos0/svu v1.12.0 // indirect
23+
github.com/ccojocar/zxcvbn-go v1.0.4 // indirect
24+
github.com/felixge/httpsnoop v1.0.4 // indirect
25+
github.com/go-logr/logr v1.4.3 // indirect
26+
github.com/go-logr/stdr v1.2.2 // indirect
27+
github.com/gobwas/glob v0.2.3 // indirect
28+
github.com/google/generative-ai-go v0.20.1 // indirect
29+
github.com/google/s2a-go v0.1.9 // indirect
30+
github.com/google/uuid v1.6.0 // indirect
31+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
32+
github.com/googleapis/gax-go/v2 v2.14.2 // indirect
33+
github.com/gookit/color v1.5.4 // indirect
34+
github.com/securego/gosec/v2 v2.22.7 // indirect
35+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
36+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
37+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
38+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
39+
go.opentelemetry.io/otel v1.36.0 // indirect
40+
go.opentelemetry.io/otel/metric v1.36.0 // indirect
41+
go.opentelemetry.io/otel/trace v1.36.0 // indirect
42+
golang.org/x/crypto v0.41.0 // indirect
43+
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect
44+
golang.org/x/oauth2 v0.30.0 // indirect
45+
golang.org/x/sync v0.16.0 // indirect
46+
golang.org/x/sys v0.35.0 // indirect
47+
golang.org/x/telemetry v0.0.0-20250710130107-8d8967aff50b // indirect
48+
golang.org/x/text v0.28.0 // indirect
49+
golang.org/x/time v0.12.0 // indirect
50+
golang.org/x/tools v0.35.0 // indirect
51+
golang.org/x/tools/go/expect v0.1.1-deprecated // indirect
52+
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated // indirect
53+
golang.org/x/vuln v1.1.4 // indirect
54+
google.golang.org/api v0.242.0 // indirect
55+
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
56+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
57+
google.golang.org/grpc v1.73.0 // indirect
58+
google.golang.org/protobuf v1.36.6 // indirect
1459
gopkg.in/yaml.v3 v3.0.1 // indirect
60+
honnef.co/go/tools v0.6.1 // indirect
1561
)
62+
63+
tool github.com/caarlos0/svu
64+
65+
tool github.com/securego/gosec/v2/cmd/gosec
66+
67+
tool golang.org/x/vuln/cmd/govulncheck
68+
69+
tool honnef.co/go/tools/cmd/staticcheck

0 commit comments

Comments
 (0)