go-ceph/rgw/admin/errors_test.go
Simon Jürgensmeyer 9604e19a0e rgw/admin: add ErrNoSuchSubUser
Signed-off-by: Simon Jürgensmeyer <simon.juergensmeyer@hetzner-cloud.de>
2024-06-13 14:37:59 +00:00

24 lines
694 B
Go

package admin
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
var (
fakeGetUserError = []byte(`{"Code":"NoSuchUser","RequestId":"tx0000000000000000005a9-00608957a2-10496-my-store","HostId":"10496-my-store-my-store"}`)
fakeGetSubUserError = []byte(`{"Code":"NoSuchSubUser","RequestId":"tx0000000000000000005a9-00608957a2-10496-my-store","HostId":"10496-my-store-my-store"}`)
)
func TestHandleStatusError(t *testing.T) {
err := handleStatusError(fakeGetUserError)
assert.Error(t, err)
assert.True(t, errors.Is(err, ErrNoSuchUser), err)
err = handleStatusError(fakeGetSubUserError)
assert.Error(t, err)
assert.True(t, errors.Is(err, ErrNoSuchSubUser), err)
}