Files
kata-containers/virtcontainers/device/drivers/generic_test.go
Ganesh Maharaj Mahalingam f4428761cb lint: Update go linter from gometalinter to golangci-lint.
gometalinter is deprecated and will be archived April '19. The
suggestion is to switch to golangci-lint which is apparently 5x faster
than gometalinter.

Partially Fixes: #1377

Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
2019-03-25 08:48:13 -07:00

45 lines
872 B
Go

// Copyright (c) 2018 Huawei Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package drivers
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBumpAttachCount(t *testing.T) {
type testData struct {
attachCount uint
expectedAC uint
attach bool
expectSkip bool
expectErr bool
}
data := []testData{
{0, 1, true, false, false},
{1, 2, true, true, false},
{intMax, intMax, true, true, true},
{0, 0, false, true, true},
{1, 0, false, false, false},
{intMax, intMax - 1, false, true, false},
}
dev := &GenericDevice{}
for _, d := range data {
dev.AttachCount = d.attachCount
skip, err := dev.bumpAttachCount(d.attach)
assert.Equal(t, skip, d.expectSkip, "")
assert.Equal(t, dev.GetAttachCount(), d.expectedAC, "")
if d.expectErr {
assert.NotNil(t, err)
} else {
assert.Nil(t, err)
}
}
}