mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-11 14:39:28 +02:00
test: group by id
This commit is contained in:
parent
aad1e1e3d5
commit
45c0e2bcaf
@ -256,6 +256,10 @@ func (artifacts Artifacts) List() []*Artifact {
|
||||
func (artifacts Artifacts) GroupByID() map[string][]*Artifact {
|
||||
result := map[string][]*Artifact{}
|
||||
for _, a := range artifacts.items {
|
||||
id := a.ID()
|
||||
if id == "" {
|
||||
continue
|
||||
}
|
||||
result[a.ID()] = append(result[a.ID()], a)
|
||||
}
|
||||
return result
|
||||
|
@ -181,6 +181,58 @@ func TestRemove(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestGroupByID(t *testing.T) {
|
||||
data := []*Artifact{
|
||||
{
|
||||
Name: "foo",
|
||||
Extra: map[string]interface{}{
|
||||
ExtraID: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "bar",
|
||||
Extra: map[string]interface{}{
|
||||
ExtraID: "foo",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "foobar",
|
||||
Goos: "linux",
|
||||
Extra: map[string]interface{}{
|
||||
ExtraID: "foovar",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "foobar",
|
||||
Goos: "linux",
|
||||
Extra: map[string]interface{}{
|
||||
ExtraID: "foovar",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "foobar",
|
||||
Goos: "linux",
|
||||
Extra: map[string]interface{}{
|
||||
ExtraID: "foobar",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "check",
|
||||
Type: Checksum,
|
||||
},
|
||||
}
|
||||
artifacts := New()
|
||||
for _, a := range data {
|
||||
artifacts.Add(a)
|
||||
}
|
||||
|
||||
groups := artifacts.GroupByID()
|
||||
require.Len(t, groups["foo"], 2)
|
||||
require.Len(t, groups["foobar"], 1)
|
||||
require.Len(t, groups["foovar"], 2)
|
||||
require.Len(t, groups, 3)
|
||||
}
|
||||
|
||||
func TestGroupByPlatform(t *testing.T) {
|
||||
data := []*Artifact{
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user