mirror of
https://github.com/Quiq/docker-registry-ui.git
synced 2025-09-08 00:18:56 +00:00
Initial commit.
This commit is contained in:
47
registry/common_test.go
Normal file
47
registry/common_test.go
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user