mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-24 01:24:26 +01:00
proxy/shim: add unit tests
To test built-in proxy and shim types. Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
42
virtcontainers/podlist_test.go
Normal file
42
virtcontainers/podlist_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Copyright (c) 2018 HyperHQ Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package virtcontainers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPodListOperations(t *testing.T) {
|
||||
p := &Pod{id: "testpodListpod"}
|
||||
l := &podList{pods: make(map[string]*Pod)}
|
||||
err := l.addPod(p)
|
||||
assert.Nil(t, err, "addPod failed")
|
||||
|
||||
err = l.addPod(p)
|
||||
assert.NotNil(t, err, "add same pod should fail")
|
||||
|
||||
np, err := l.lookupPod(p.id)
|
||||
assert.Nil(t, err, "lookupPod failed")
|
||||
assert.Equal(t, np, p, "lookupPod returns different pod %v:%v", np, p)
|
||||
|
||||
_, err = l.lookupPod("some-non-existing-pod-name")
|
||||
assert.NotNil(t, err, "lookupPod for non-existing pod should fail")
|
||||
|
||||
l.removePod(p.id)
|
||||
}
|
||||
Reference in New Issue
Block a user