Verify platform is stored in state directly in defop test

Signed-off-by: Edgar Lee <edgarl@netflix.com>
v0.7
Edgar Lee 2020-01-13 16:56:45 -08:00
parent 0a76749067
commit f937656b1a
2 changed files with 21 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes"
"testing"
"github.com/containerd/containerd/platforms"
"github.com/stretchr/testify/require"
)
@ -49,6 +50,16 @@ func TestDefinitionEquivalence(t *testing.T) {
for dgst := range def.Metadata {
require.Equal(t, def.Metadata[dgst], def2.Metadata[dgst])
}
expectedPlatform := tc.state.GetPlatform()
actualPlatform := st2.GetPlatform()
if expectedPlatform == nil && actualPlatform != nil {
defaultPlatform := platforms.Normalize(platforms.DefaultSpec())
expectedPlatform = &defaultPlatform
}
require.Equal(t, expectedPlatform, actualPlatform)
})
}
}

View File

@ -118,13 +118,20 @@ func (c *grpcClient) Run(ctx context.Context, f client.BuildFunc) (retError erro
}
pbRes.Result = &pb.Result_Refs{Refs: &pb.RefMap{Refs: m}}
} else {
// Server doesn't support the new wire format for refs, so we construct
// a deprecated result ref map.
m := map[string]string{}
for k, r := range res.Refs {
id, err := convertRef(r)
pbRef, err := convertRef(r)
if err != nil {
retError = err
continue
}
var id string
if len(pbRef.Ids) > 0 {
id = pbRef.Ids[0]
}
m[k] = id
}
pbRes.Result = &pb.Result_RefsDeprecated{RefsDeprecated: &pb.RefMapDeprecated{Refs: m}}
@ -137,6 +144,8 @@ func (c *grpcClient) Run(ctx context.Context, f client.BuildFunc) (retError erro
if c.caps.Supports(pb.CapProtoRefArray) == nil {
pbRes.Result = &pb.Result_Ref{Ref: pbRef}
} else {
// Server doesn't support the new wire format for refs, so we construct
// a deprecated result ref.
var id string
if len(pbRef.Ids) > 0 {
id = pbRef.Ids[0]