github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/commands/pluginrepo/list_plugin_repos_test.go (about)

     1  package pluginrepo_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/cf/commandregistry"
     5  	"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
     6  	"code.cloudfoundry.org/cli/cf/models"
     7  	"code.cloudfoundry.org/cli/cf/requirements/requirementsfakes"
     8  
     9  	testcmd "code.cloudfoundry.org/cli/util/testhelpers/commands"
    10  	testconfig "code.cloudfoundry.org/cli/util/testhelpers/configuration"
    11  	testterm "code.cloudfoundry.org/cli/util/testhelpers/terminal"
    12  
    13  	. "code.cloudfoundry.org/cli/util/testhelpers/matchers"
    14  
    15  	. "github.com/onsi/ginkgo"
    16  	. "github.com/onsi/gomega"
    17  )
    18  
    19  var _ = Describe("list-plugin-repo", func() {
    20  	var (
    21  		ui                  *testterm.FakeUI
    22  		config              coreconfig.Repository
    23  		requirementsFactory *requirementsfakes.FakeFactory
    24  		deps                commandregistry.Dependency
    25  	)
    26  
    27  	updateCommandDependency := func(pluginCall bool) {
    28  		deps.UI = ui
    29  		deps.Config = config
    30  		commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("list-plugin-repos").SetDependency(deps, pluginCall))
    31  	}
    32  
    33  	BeforeEach(func() {
    34  		ui = &testterm.FakeUI{}
    35  		requirementsFactory = new(requirementsfakes.FakeFactory)
    36  		config = testconfig.NewRepositoryWithDefaults()
    37  	})
    38  
    39  	var callListPluginRepos = func(args ...string) bool {
    40  		return testcmd.RunCLICommand("list-plugin-repos", args, requirementsFactory, updateCommandDependency, false, ui)
    41  	}
    42  
    43  	It("lists all added plugin repo in a table", func() {
    44  		config.SetPluginRepo(models.PluginRepo{
    45  			Name: "repo1",
    46  			URL:  "http://url1.com",
    47  		})
    48  		config.SetPluginRepo(models.PluginRepo{
    49  			Name: "repo2",
    50  			URL:  "http://url2.com",
    51  		})
    52  
    53  		callListPluginRepos()
    54  
    55  		Expect(ui.Outputs()).To(ContainSubstrings(
    56  			[]string{"repo1", "http://url1.com"},
    57  			[]string{"repo2", "http://url2.com"},
    58  		))
    59  
    60  	})
    61  
    62  })