github.com/joomcode/pegomock@v2.9.2-0.20220414140958-14f53b6b2a6c+incompatible/mockgen/util/util_test.go (about) 1 package util_test 2 3 import ( 4 "github.com/onsi/ginkgo" 5 . "github.com/onsi/ginkgo" 6 "github.com/onsi/gomega" 7 . "github.com/onsi/gomega" 8 "github.com/petergtz/pegomock/mockgen/util" 9 "testing" 10 ) 11 12 func TestUtil(t *testing.T) { 13 gomega.RegisterFailHandler(ginkgo.Fail) 14 ginkgo.RunSpecs(t, "Util Suite") 15 } 16 17 var _ = Describe("util", func() { 18 Context("sort", func() { 19 It("SortedKeys returns map keys in alphabetical order", func() { 20 importPaths := map[string]bool{ 21 "github.com/b/mypackage": true, 22 "github.com/c/mypackage": true, 23 "github.com/a/mypackage": true, 24 } 25 26 sortedImportPaths := util.SortedKeys(importPaths) 27 Expect(sortedImportPaths).To(HaveLen(3)) 28 Expect(sortedImportPaths[0]).To(Equal("github.com/a/mypackage")) 29 Expect(sortedImportPaths[1]).To(Equal("github.com/b/mypackage")) 30 Expect(sortedImportPaths[2]).To(Equal("github.com/c/mypackage")) 31 }) 32 }) 33 })