frostfs-rest-gw/internal/util/transformers_test.go
Alex Vanin 7b05338492 [#2] Update integration test to FrostFS AIO image
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2023-06-28 17:44:52 +03:00

27 lines
781 B
Go

package util
import (
"encoding/json"
"errors"
"fmt"
"testing"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
"github.com/stretchr/testify/require"
)
func TestErrors(t *testing.T) {
apiErr := fmt.Errorf("some context: %w", apistatus.ContainerNotFound{})
resp := NewErrorResponse(apiErr)
data, err := json.Marshal(resp)
require.NoError(t, err)
require.Equal(t, `{"code":3072,"message":"some context: status: code = 3072 message = container not found","type":"API"}`, string(data))
gwErr := fmt.Errorf("some context: %w", errors.New("sanity check error"))
resp = NewErrorResponse(gwErr)
data, err = json.Marshal(resp)
require.NoError(t, err)
require.Equal(t, `{"message":"some context: sanity check error","type":"GW"}`, string(data))
}