Files
kata-containers/containerd-shim-v2/errors_test.go
Peng Tao 8215a3ce9a shimv2: convert vc errors to grpc errors
containerd checks for the grpc error code to determine
correct recover action upon grpc errors. We need to provide
them properly.

Unfortunately ttrpc doesn't support grpc interceptor so we have
to modify every service function for it.

Fixes: #1527

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
2019-04-12 03:57:01 -07:00

30 lines
674 B
Go

// Copyright (c) 2019 hyper.sh
//
// SPDX-License-Identifier: Apache-2.0
//
package containerdshim
import (
"syscall"
"testing"
vc "github.com/kata-containers/runtime/virtcontainers/pkg/types"
"github.com/stretchr/testify/assert"
)
func TestToGRPC(t *testing.T) {
assert := assert.New(t)
for _, err := range []error{vc.ErrNeedSandbox, vc.ErrNeedSandboxID,
vc.ErrNeedContainerID, vc.ErrNeedState, syscall.EINVAL, vc.ErrNoSuchContainer, syscall.ENOENT} {
assert.False(isGRPCError(err))
err = toGRPC(err)
assert.True(isGRPCError(err))
err = toGRPC(err)
assert.True(isGRPCError(err))
err = toGRPCf(err, "appending")
assert.True(isGRPCError(err))
}
}