github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/util/configv3/plugin_repository_test.go (about) 1 package configv3_test 2 3 import ( 4 . "code.cloudfoundry.org/cli/util/configv3" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 ) 9 10 var _ = Describe("PluginRepository", func() { 11 Describe("PluginRepositories", func() { 12 It("returns sorted plugin repositories", func() { 13 config := Config{ 14 ConfigFile: JSONConfig{ 15 PluginRepositories: []PluginRepository{ 16 {Name: "S-repo", URL: "S-repo.com"}, 17 {Name: "repo-2", URL: "repo2.com"}, 18 {Name: "repo-1", URL: "repo1.com"}, 19 }, 20 }, 21 } 22 23 Expect(config.PluginRepositories()).To(Equal([]PluginRepository{ 24 {Name: "repo-1", URL: "repo1.com"}, 25 {Name: "repo-2", URL: "repo2.com"}, 26 {Name: "S-repo", URL: "S-repo.com"}, 27 })) 28 }) 29 }) 30 31 Describe("AddPluginRepository", func() { 32 It("adds the repo name and url to the list of repositories", func() { 33 config := Config{ 34 ConfigFile: JSONConfig{ 35 PluginRepositories: []PluginRepository{ 36 {Name: "S-repo", URL: "S-repo.com"}, 37 {Name: "repo-2", URL: "repo2.com"}, 38 {Name: "repo-1", URL: "repo1.com"}, 39 }, 40 }, 41 } 42 43 config.AddPluginRepository("some-repo", "some-URL") 44 Expect(config.PluginRepositories()).To(ContainElement(PluginRepository{Name: "some-repo", URL: "some-URL"})) 45 }) 46 }) 47 })