forked from TrueCloudLab/frostfs-api-go
[#223] pkg/object: Work with SplitInfoError via pointer
Closes #221 Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
b683dbe7e6
commit
1fe0307711
2 changed files with 8 additions and 7 deletions
|
@ -6,14 +6,14 @@ type SplitInfoError struct {
|
||||||
|
|
||||||
const splitInfoErrorMsg = "object not found, split info has been provided"
|
const splitInfoErrorMsg = "object not found, split info has been provided"
|
||||||
|
|
||||||
func (s SplitInfoError) Error() string {
|
func (s *SplitInfoError) Error() string {
|
||||||
return splitInfoErrorMsg
|
return splitInfoErrorMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SplitInfoError) SplitInfo() *SplitInfo {
|
func (s *SplitInfoError) SplitInfo() *SplitInfo {
|
||||||
return s.si
|
return s.si
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSplitInfoError(v *SplitInfo) SplitInfoError {
|
func NewSplitInfoError(v *SplitInfo) *SplitInfoError {
|
||||||
return SplitInfoError{si: v}
|
return &SplitInfoError{si: v}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,13 @@ func TestNewSplitInfoError(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
si = generateSplitInfo()
|
si = generateSplitInfo()
|
||||||
|
|
||||||
err error = object.NewSplitInfoError(si)
|
err error = object.NewSplitInfoError(si)
|
||||||
|
expectedErr *object.SplitInfoError
|
||||||
)
|
)
|
||||||
|
|
||||||
require.True(t, errors.As(err, new(object.SplitInfoError)))
|
require.True(t, errors.As(err, &expectedErr))
|
||||||
|
|
||||||
siErr, ok := err.(object.SplitInfoError)
|
siErr, ok := err.(*object.SplitInfoError)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.Equal(t, si, siErr.SplitInfo())
|
require.Equal(t, si, siErr.SplitInfo())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue