From a56f76acdc8c3e1789992fca09a3e16ef3a0325d Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Sat, 12 Oct 2024 19:12:27 +0200 Subject: [PATCH] fix all linting errors, add benchmark to Makefile --- Makefile | 2 ++ lib_test.go | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 822e4e0..ac4ba96 100644 --- a/Makefile +++ b/Makefile @@ -37,3 +37,5 @@ release: buildlocal test gh release create v$(VERSION) --generate-notes +bench: + go test -bench=. -count 5 diff --git a/lib_test.go b/lib_test.go index 72b1514..6b2ad7f 100644 --- a/lib_test.go +++ b/lib_test.go @@ -256,7 +256,10 @@ func BenchmarkValidateEntropy(b *testing.B) { passwords := GetPasswords(b.N) for i := 0; i < b.N; i++ { - valpass.Validate(passwords[i], valpass.Options{Entropy: 10}) + _, err := valpass.Validate(passwords[i], valpass.Options{Entropy: 10}) + if err != nil { + panic(err) + } } } @@ -264,7 +267,10 @@ func BenchmarkValidateCharDist(b *testing.B) { passwords := GetPasswords(b.N) for i := 0; i < b.N; i++ { - valpass.Validate(passwords[i], valpass.Options{CharDistribution: 10}) + _, err := valpass.Validate(passwords[i], valpass.Options{CharDistribution: 10}) + if err != nil { + panic(err) + } } } @@ -272,7 +278,10 @@ func BenchmarkValidateCompress(b *testing.B) { passwords := GetPasswords(b.N) for i := 0; i < b.N; i++ { - valpass.Validate(passwords[i], valpass.Options{Compress: 10}) + _, err := valpass.Validate(passwords[i], valpass.Options{Compress: 10}) + if err != nil { + panic(err) + } } } @@ -280,9 +289,12 @@ func BenchmarkValidateDict(b *testing.B) { passwords := GetPasswords(b.N) for i := 0; i < b.N; i++ { - valpass.Validate(passwords[i], + _, err := valpass.Validate(passwords[i], valpass.Options{Dictionary: &valpass.Dictionary{Words: ReadDict("t/american-english")}}, ) + if err != nil { + panic(err) + } } } @@ -290,7 +302,10 @@ func BenchmarkValidateAll(b *testing.B) { passwords := GetPasswords(b.N) for i := 0; i < b.N; i++ { - valpass.Validate(passwords[i]) + _, err := valpass.Validate(passwords[i]) + if err != nil { + panic(err) + } } }