mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 00:47:33 +00:00
chore: move the go code into a subfolder
This commit is contained in:
44
apps/api/internal/zerrors/zerror_test.go
Normal file
44
apps/api/internal/zerrors/zerror_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package zerrors_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
func TestErrorMethod(t *testing.T) {
|
||||
err := zerrors.ThrowError(nil, "id", "msg")
|
||||
expected := "ID=id Message=msg"
|
||||
assert.Equal(t, expected, err.Error())
|
||||
|
||||
err = zerrors.ThrowError(err, "subID", "subMsg")
|
||||
subExptected := "ID=subID Message=subMsg Parent=(ID=id Message=msg)"
|
||||
assert.Equal(t, subExptected, err.Error())
|
||||
}
|
||||
|
||||
func TestIsZitadelError(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
err error
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "zitadel error",
|
||||
err: zerrors.ThrowInvalidArgument(nil, "id", "msg"),
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "other error",
|
||||
err: errors.New("just a random error"),
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
assert.Equalf(t, tt.want, zerrors.IsZitadelError(tt.err), "IsZitadelError(%v)", tt.err)
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user