Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add resource type. #528

Merged
merged 4 commits into from
Mar 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sort attributes in test to fix ci.
  • Loading branch information
rghetia committed Mar 7, 2020
commit 822183ffdc55903d6777e8ab0fcb06610202cec7
18 changes: 16 additions & 2 deletions sdk/resource/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package resource_test

import (
"fmt"
"sort"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -55,7 +56,10 @@ func TestNew(t *testing.T) {
for _, c := range cases {
t.Run(fmt.Sprintf("case-%s", c.name), func(t *testing.T) {
res := resource.New(c.in...)
if diff := cmp.Diff(res.Attributes(), c.want, cmp.AllowUnexported(core.Value{})); diff != "" {
if diff := cmp.Diff(
sortedAttributes(res.Attributes()),
sortedAttributes(c.want),
cmp.AllowUnexported(core.Value{})); diff != "" {
t.Fatalf("unwanted result: diff %+v,", diff)
}
})
Expand Down Expand Up @@ -96,9 +100,19 @@ func TestMerge(t *testing.T) {
for _, c := range cases {
t.Run(fmt.Sprintf("case-%s", c.name), func(t *testing.T) {
res := resource.Merge(c.a, c.b)
if diff := cmp.Diff(res.Attributes(), c.want, cmp.AllowUnexported(core.Value{})); diff != "" {
if diff := cmp.Diff(
sortedAttributes(res.Attributes()),
sortedAttributes(c.want),
cmp.AllowUnexported(core.Value{})); diff != "" {
t.Fatalf("unwanted result: diff %+v,", diff)
}
})
}
}

func sortedAttributes(attrs []core.KeyValue) []core.KeyValue {
sort.Slice(attrs[:], func(i, j int) bool {
return attrs[i].Key < attrs[j].Key
})
return attrs
}