|
| 1 | +//go:build integration |
| 2 | + |
| 3 | +package integration |
| 4 | + |
| 5 | +import ( |
| 6 | + "path/filepath" |
| 7 | + "testing" |
| 8 | + |
| 9 | + "get.porter.sh/porter/tests/tester" |
| 10 | + "github.com/carolynvs/magex/shx" |
| 11 | + "github.com/stretchr/testify/require" |
| 12 | +) |
| 13 | + |
| 14 | +func TestLint(t *testing.T) { |
| 15 | + test, err := tester.NewTest(t) |
| 16 | + defer test.Close() |
| 17 | + require.NoError(t, err, "test setup failed") |
| 18 | + |
| 19 | + // When a mixin doesn't support lint, we should not print that to the console unless we are in debug mode |
| 20 | + _, output, _ := test.RunPorterWith(func(cmd *shx.PreparedCommand) { |
| 21 | + cmd.Args("lint") |
| 22 | + // mybuns uses the testmixin which doesn't support lint |
| 23 | + cmd.In(filepath.Join(test.RepoRoot, "tests/testdata/mybuns")) |
| 24 | + // change verbosity to debug so that we see the error |
| 25 | + cmd.Env("PORTER_VERBOSITY=debug") |
| 26 | + }) |
| 27 | + require.Contains(t, output, "unknown command", "an unsupported mixin command should print to the console in debug") |
| 28 | + |
| 29 | + _, output, _ = test.RunPorterWith(func(cmd *shx.PreparedCommand) { |
| 30 | + cmd.Args("lint") |
| 31 | + // mybuns uses the testmixin which doesn't support lint |
| 32 | + cmd.In(filepath.Join(test.RepoRoot, "tests/testdata/mybuns")) |
| 33 | + // errors are printed at the debug level to bump it up to info |
| 34 | + cmd.Env("PORTER_VERBOSITY=info") |
| 35 | + }) |
| 36 | + require.NotContains(t, output, "unknown command", "an unsupported mixin command should not be printed to the console in info") |
| 37 | + |
| 38 | +} |
0 commit comments