Skip to content

Commit

Permalink
Add some minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Reinhard Nägele <[email protected]>
  • Loading branch information
unguiculus committed Dec 19, 2018
1 parent 17dc981 commit 87782c1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
7 changes: 3 additions & 4 deletions app/cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"os"

"github.com/MakeNowJust/heredoc"

"github.com/helm/chart-testing/pkg/chart"
"github.com/helm/chart-testing/pkg/config"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -65,13 +64,13 @@ func addLintFlags(flags *flag.FlagSet) {
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
that order.`))
flags.Bool("validate-maintainers", true, heredoc.Doc(`
Enabled validation of maintainer account names in chart.yml (default: true).
Enable validation of maintainer account names in chart.yml (default: true).
Works for GitHub, GitLab, and Bitbucket`))
flags.Bool("check-version-increment", true, "Activates a check for chart version increments (default: true)")
flags.Bool("validate-chart-schema", true, heredoc.Doc(`
Enabled validation of the schema (default: true)`))
Enable schema validation of 'Chart.yaml' using Yamale (default: true)`))
flags.Bool("validate-yaml", true, heredoc.Doc(`
Enabled validation to lint the yaml files (default: true)`))
Enable linting of 'Chart.yaml' and values files (default: true)`))
}

func lint(cmd *cobra.Command, args []string) {
Expand Down
6 changes: 3 additions & 3 deletions doc/ct_lint-and-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ ct lint-and-install [flags]
This is only used if namespace is specified. (default "app.kubernetes.io/instance")
--remote string The name of the Git remote used to identify changed charts (default "origin")
--target-branch string The name of the target branch used to identify changed charts (default "master")
--validate-chart-schema Enabled validation of the schema (default: true) (default true)
--validate-maintainers Enabled validation of maintainer account names in chart.yml (default: true).
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default: true) (default true)
--validate-maintainers Enable validation of maintainer account names in chart.yml (default: true).
Works for GitHub, GitLab, and Bitbucket (default true)
--validate-yaml Enabled validation to lint the yaml files (default: true) (default true)
--validate-yaml Enable linting of 'Chart.yaml' and values files (default: true) (default true)
```

### SEE ALSO
Expand Down
6 changes: 3 additions & 3 deletions doc/ct_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ ct lint [flags]
that order
--remote string The name of the Git remote used to identify changed charts (default "origin")
--target-branch string The name of the target branch used to identify changed charts (default "master")
--validate-chart-schema Enabled validation of the schema (default: true) (default true)
--validate-maintainers Enabled validation of maintainer account names in chart.yml (default: true).
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default: true) (default true)
--validate-maintainers Enable validation of maintainer account names in chart.yml (default: true).
Works for GitHub, GitLab, and Bitbucket (default true)
--validate-yaml Enabled validation to lint the yaml files (default: true) (default true)
--validate-yaml Enable linting of 'Chart.yaml' and values files (default: true) (default true)
```

### SEE ALSO
Expand Down
31 changes: 13 additions & 18 deletions pkg/chart/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ import (
"strings"
"testing"

"github.com/pkg/errors"

"github.com/helm/chart-testing/pkg/util"

"github.com/helm/chart-testing/pkg/config"
"github.com/helm/chart-testing/pkg/util"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
Expand Down Expand Up @@ -95,20 +93,15 @@ func (v fakeAccountValidator) Validate(repoDomain string, account string) error
return errors.New(fmt.Sprintf("Error validating account: %s", account))
}

type fakeLinter struct{}

func (l fakeLinter) YamlLint(yamlFile, configFile string) error { return nil }
func (l fakeLinter) Yamale(yamlFile, schemaFile string) error { return nil }

type fakeLinter2 struct {
type fakeLinter struct {
mock.Mock
}

func (l *fakeLinter2) YamlLint(yamlFile, configFile string) error {
func (l *fakeLinter) YamlLint(yamlFile, configFile string) error {
l.Called(yamlFile, configFile)
return nil
}
func (l *fakeLinter2) Yamale(yamlFile, schemaFile string) error {
func (l *fakeLinter) Yamale(yamlFile, schemaFile string) error {
l.Called(yamlFile, schemaFile)
return nil
}
Expand All @@ -134,13 +127,16 @@ func init() {
ExcludedCharts: []string{"excluded"},
ChartDirs: []string{"stable", "incubator"},
}

fakeMockLinter := new(fakeLinter)

ct = Testing{
config: cfg,
directoryLister: fakeDirLister{},
git: fakeGit{},
chartUtils: fakeChartUtils{},
accountValidator: fakeAccountValidator{},
linter: fakeLinter{},
linter: fakeMockLinter,
helm: fakeHelm{},
}
}
Expand Down Expand Up @@ -222,8 +218,8 @@ func TestLintChartSchemaValidation(t *testing.T) {
expected bool
}

runTests := func(validate bool, callsYamlLint, callsYamale int) {
var fakeMockLinter = new(fakeLinter2)
runTests := func(validate bool, callsYamlLint int, callsYamale int) {
fakeMockLinter := new(fakeLinter)

fakeMockLinter.On("Yamale", mock.Anything, mock.Anything).Return(true)
fakeMockLinter.On("YamlLint", mock.Anything, mock.Anything).Return(true)
Expand Down Expand Up @@ -266,9 +262,8 @@ func TestLintYamlValidation(t *testing.T) {
expected bool
}

runTests := func(validate bool, callsYamlLint, callsYamale int) {

var fakeMockLinter = new(fakeLinter2)
runTests := func(validate bool, callsYamlLint int, callsYamale int) {
fakeMockLinter := new(fakeLinter)

fakeMockLinter.On("Yamale", mock.Anything, mock.Anything).Return(true)
fakeMockLinter.On("YamlLint", mock.Anything, mock.Anything).Return(true)
Expand Down

0 comments on commit 87782c1

Please sign in to comment.