Create AddRepo steps when there are repos to add [#26]
This commit is contained in:
@@ -177,6 +177,17 @@ func (suite *PlanTestSuite) TestUpgradeWithUpdateDependencies() {
|
||||
suite.IsType(&run.DepUpdate{}, steps[1])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUpgradeWithAddRepos() {
|
||||
cfg := Config{
|
||||
AddRepos: []string{
|
||||
"machine=https://github.com/harold_finch/themachine",
|
||||
},
|
||||
}
|
||||
steps := upgrade(cfg)
|
||||
suite.Require().True(len(steps) > 1, "upgrade should generate at least two steps")
|
||||
suite.IsType(&run.AddRepo{}, steps[1])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestUninstall() {
|
||||
cfg := Config{
|
||||
KubeToken: "b2YgbXkgYWZmZWN0aW9u",
|
||||
@@ -268,6 +279,61 @@ func (suite *PlanTestSuite) TestDepUpdate() {
|
||||
suite.Equal(expected, update)
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestAddRepos() {
|
||||
cfg := Config{
|
||||
AddRepos: []string{
|
||||
"first=https://add.repos/one",
|
||||
"second=https://add.repos/two",
|
||||
},
|
||||
}
|
||||
steps := addRepos(cfg)
|
||||
suite.Require().Equal(2, len(steps), "addRepos should add one step per repo")
|
||||
suite.Require().IsType(&run.AddRepo{}, steps[0])
|
||||
suite.Require().IsType(&run.AddRepo{}, steps[1])
|
||||
first := steps[0].(*run.AddRepo)
|
||||
second := steps[1].(*run.AddRepo)
|
||||
|
||||
suite.Equal(first.Name, "first")
|
||||
suite.Equal(first.URL, "https://add.repos/one")
|
||||
suite.Equal(second.Name, "second")
|
||||
suite.Equal(second.URL, "https://add.repos/two")
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestAddNoRepos() {
|
||||
cfg := Config{
|
||||
AddRepos: []string{},
|
||||
}
|
||||
steps := addRepos(cfg)
|
||||
suite.Equal(0, len(steps), "adding no repos should take zero steps")
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestAddReposWithMalformedRepoSpec() {
|
||||
stderr := strings.Builder{}
|
||||
cfg := Config{
|
||||
AddRepos: []string{
|
||||
"dwim",
|
||||
},
|
||||
Stderr: &stderr,
|
||||
}
|
||||
steps := addRepos(cfg)
|
||||
suite.Equal(len(steps), 0)
|
||||
suite.Equal("Warning: skipping bad repo spec 'dwim'.\n", stderr.String())
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestAddReposWithEqualsInURL() {
|
||||
cfg := Config{
|
||||
AddRepos: []string{
|
||||
"samaritan=https://github.com/arthur_claypool/samaritan?version=2.1",
|
||||
},
|
||||
Stderr: &strings.Builder{},
|
||||
}
|
||||
steps := addRepos(cfg)
|
||||
suite.Require().Equal(1, len(steps))
|
||||
suite.Require().IsType(&run.AddRepo{}, steps[0])
|
||||
addRepo := steps[0].(*run.AddRepo)
|
||||
suite.Equal("https://github.com/arthur_claypool/samaritan?version=2.1", addRepo.URL)
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestLint() {
|
||||
cfg := Config{
|
||||
Chart: "./flow",
|
||||
@@ -291,6 +357,15 @@ func (suite *PlanTestSuite) TestLintWithUpdateDependencies() {
|
||||
suite.IsType(&run.DepUpdate{}, steps[0])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestLintWithAddRepos() {
|
||||
cfg := Config{
|
||||
AddRepos: []string{"friendczar=https://github.com/logan_pierce/friendczar"},
|
||||
}
|
||||
steps := lint(cfg)
|
||||
suite.Require().True(len(steps) > 0, "lint should return at least one step")
|
||||
suite.IsType(&run.AddRepo{}, steps[0])
|
||||
}
|
||||
|
||||
func (suite *PlanTestSuite) TestDeterminePlanUpgradeCommand() {
|
||||
cfg := Config{
|
||||
Command: "upgrade",
|
||||
|
||||
Reference in New Issue
Block a user