Skip to content

Commit

Permalink
Merge pull request #4 from pasqal-io/yoric/env
Browse files Browse the repository at this point in the history
Improving code hygiene
  • Loading branch information
David Teller authored Dec 26, 2023
2 parents e4f4023 + b7b6956 commit 738a573
Show file tree
Hide file tree
Showing 14 changed files with 1,016 additions and 451 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.orig
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ linters:
- gosmopolitan
- govet
- mirror
- nolintlint
- nosprintfhostport
- perfsprint
- prealloc
Expand All @@ -35,7 +34,6 @@ linters:
- revive
- sloglint
- sqlclosecheck
- staticcheck
- tagliatelle
- tenv
- testableexamples
Expand All @@ -47,6 +45,8 @@ linters:
- unused
- usestdlibvars
- wrapcheck
disable:
- staticcheck # already built into Go

linters-settings:
exhaustive:
Expand Down
30 changes: 0 additions & 30 deletions assertions/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,9 @@ package testutils
import (
"encoding/json"
"fmt"
"reflect"
"regexp"
"testing"
)

// Fail if two values are different.
//
// Does not stop the test.
func AssertEqual[T comparable](t *testing.T, actual, expected T, explanation string) {
t.Helper()
if expected != actual {
t.Errorf("got: %+v; want: %+v (%s)", actual, expected, explanation)
if reflect.ValueOf(expected).Kind() == reflect.Pointer {
t.Error("Warning: you're comparing two pointers -- pointers are only equal if they point to the same physical object")
}
}
}
func AssertEqualArrays[T comparable](t *testing.T, actual, expected []T, explanation string) {
t.Helper()
AssertEqual(t, len(actual), len(expected), explanation)
for i := 0; i < len(actual); i++ {
AssertEqual(t, actual[i], expected[i], explanation)
}
}

func AssertRegexp(t *testing.T, actual string, pattern regexp.Regexp, explanation string) {
t.Helper()
if pattern.FindStringIndex(actual) != nil {
return
}
t.Errorf("got: %+v; expected: %+v (%s)", actual, pattern, explanation)
}

func Unmarshal[T any](t *testing.T, payload []byte) (*T, error) {
t.Helper()

Expand Down
Loading

0 comments on commit 738a573

Please sign in to comment.