Initial commit.

This commit is contained in:
Roman Vynar
2018-02-19 17:12:59 +02:00
commit 8174df6fd7
20 changed files with 1411 additions and 0 deletions

47
registry/common_test.go Normal file
View File

@@ -0,0 +1,47 @@
package registry
import (
"testing"
"time"
"github.com/smartystreets/goconvey/convey"
)
func TestSortedMapKeys(t *testing.T) {
a := map[string]string{
"foo": "bar",
"abc": "bar",
"zoo": "bar",
}
b := map[string]timeSlice{
"zoo": []tagData{tagData{name: "1", created: time.Now()}},
"abc": []tagData{tagData{name: "1", created: time.Now()}},
"foo": []tagData{tagData{name: "1", created: time.Now()}},
}
c := map[string][]string{
"zoo": []string{"1", "2"},
"foo": []string{"1", "2"},
"abc": []string{"1", "2"},
}
expect := []string{"abc", "foo", "zoo"}
convey.Convey("Sort map keys", t, func() {
convey.So(SortedMapKeys(a), convey.ShouldResemble, expect)
convey.So(SortedMapKeys(b), convey.ShouldResemble, expect)
convey.So(SortedMapKeys(c), convey.ShouldResemble, expect)
})
}
func TestPrettySize(t *testing.T) {
convey.Convey("Format bytes", t, func() {
input := map[float64]string{
123: "123 B",
23123: "23 KB",
23923: "23 KB",
723425120: "690 MB",
8534241213: "8 GB",
}
for key, val := range input {
convey.So(PrettySize(key), convey.ShouldEqual, val)
}
})
}