github.com/justincormack/cli@v0.0.0-20201215022714-831ebeae9675/cli/command/trust/common_test.go (about)

     1  package trust
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/docker/cli/cli/trust"
     7  	"github.com/theupdateframework/notary/client"
     8  	"github.com/theupdateframework/notary/tuf/data"
     9  	"gotest.tools/v3/assert"
    10  	is "gotest.tools/v3/assert/cmp"
    11  )
    12  
    13  func TestMatchReleasedSignaturesSortOrder(t *testing.T) {
    14  	var releasesRole = data.DelegationRole{BaseRole: data.BaseRole{Name: trust.ReleasesRole}}
    15  	targets := []client.TargetSignedStruct{
    16  		{Target: client.Target{Name: "target10-foo"}, Role: releasesRole},
    17  		{Target: client.Target{Name: "target1-foo"}, Role: releasesRole},
    18  		{Target: client.Target{Name: "target2-foo"}, Role: releasesRole},
    19  	}
    20  
    21  	rows := matchReleasedSignatures(targets)
    22  
    23  	var targetNames []string
    24  	for _, r := range rows {
    25  		targetNames = append(targetNames, r.SignedTag)
    26  	}
    27  	expected := []string{
    28  		"target1-foo",
    29  		"target2-foo",
    30  		"target10-foo",
    31  	}
    32  	assert.Check(t, is.DeepEqual(expected, targetNames))
    33  }