Fix tests

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato
2022-04-21 17:36:37 +00:00
parent aefd1849b6
commit 7a4f81d8ba
6 changed files with 127 additions and 49 deletions

View File

@@ -17,14 +17,13 @@
package metadata
import (
"reflect"
"testing"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/protobuf"
"github.com/containerd/containerd/protobuf/types"
api "github.com/containerd/containerd/sandbox"
"github.com/containerd/typeurl"
"github.com/google/go-cmp/cmp"
)
func TestSandboxCreate(t *testing.T) {
@@ -266,27 +265,8 @@ func TestSandboxDelete(t *testing.T) {
}
func assertEqualInstances(t *testing.T, x, y api.Sandbox) {
if x.ID != y.ID {
t.Fatalf("ids are not equal: %q != %q", x.ID, y.ID)
}
if !reflect.DeepEqual(x.Labels, y.Labels) {
t.Fatalf("labels are not equal: %+v != %+v", x.Labels, y.Labels)
}
if !reflect.DeepEqual(x.Spec, y.Spec) {
t.Fatalf("specs are not equal: %+v != %+v", x.Spec, y.Spec)
}
if !reflect.DeepEqual(x.Extensions, y.Extensions) {
t.Fatalf("extensions are not equal: %+v != %+v", x.Extensions, y.Extensions)
}
if x.Runtime.Name != y.Runtime.Name {
t.Fatalf("runtime names are not equal: %q != %q", x.Runtime.Name, y.Runtime.Name)
}
if !reflect.DeepEqual(protobuf.FromAny(x.Runtime.Options), protobuf.FromAny(y.Runtime.Options)) {
t.Fatalf("runtime options are not equal: %+v != %+v", x.Runtime.Options, y.Runtime.Options)
diff := cmp.Diff(x, y, compareNil, compareAny, ignoreTime)
if diff != "" {
t.Fatalf("x and y are different: %s", diff)
}
}