forked from TrueCloudLab/frostfs-sdk-go
[#140] apistatus: Support ACCESS_DENIED
error
Define `ObjectAccessDenied` type for `ACCESS_DENIED` code. Provide method to write/read human-readable reason. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2b28f91a89
commit
3e94b7c892
4 changed files with 90 additions and 0 deletions
26
client/status/object_test.go
Normal file
26
client/status/object_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package apistatus_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestObjectAccessDenied_WriteReason(t *testing.T) {
|
||||
const reason = "any reason"
|
||||
|
||||
var st apistatus.ObjectAccessDenied
|
||||
|
||||
res := st.Reason()
|
||||
require.Empty(t, res)
|
||||
detailNum := apistatus.ToStatusV2(st).NumberOfDetails()
|
||||
require.Zero(t, detailNum)
|
||||
|
||||
st.WriteReason(reason)
|
||||
|
||||
res = st.Reason()
|
||||
require.Equal(t, reason, res)
|
||||
detailNum = apistatus.ToStatusV2(st).NumberOfDetails()
|
||||
require.EqualValues(t, 1, detailNum)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue