From 20ef0d92694465ac86b550df139e8366a0a2b4fa Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 22 Jul 2025 17:35:49 -0600 Subject: feat: connect to spicedb --- .../authzed/spicedb/pkg/spiceerrors/bug.go | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 vendor/github.com/authzed/spicedb/pkg/spiceerrors/bug.go (limited to 'vendor/github.com/authzed/spicedb/pkg/spiceerrors/bug.go') diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/bug.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/bug.go new file mode 100644 index 0000000..7680c33 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/bug.go @@ -0,0 +1,35 @@ +package spiceerrors + +import ( + "fmt" + "os" + "strings" + + "github.com/go-errors/errors" +) + +// IsInTests returns true if go test is running +// Based on: https://stackoverflow.com/a/58945030 +func IsInTests() bool { + for _, arg := range os.Args { + if strings.HasPrefix(arg, "-test.") { + return true + } + } + return false +} + +// MustPanic is a special function for panicing when necessary to violate the linter. +func MustPanic(format string, args ...any) { + panic(fmt.Sprintf(format, args...)) +} + +// MustBugf returns an error representing a bug in the system. Will panic if run under testing. +func MustBugf(format string, args ...any) error { + if IsInTests() { + panic(fmt.Sprintf(format, args...)) + } + + e := errors.Errorf(format, args...) + return fmt.Errorf("BUG: %s", e.ErrorStack()) +} -- cgit v1.2.3