Verify platform is stored in state directly in defop test
Signed-off-by: Edgar Lee <edgarl@netflix.com>v0.7
parent
0a76749067
commit
f937656b1a
|
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue