get.porter.sh/porter@v1.3.0/tests/integration/lint_test.go (about) 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/stretchr/testify/require" 11 "github.com/uwu-tools/magex/shx" 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 39 func TestLint_ApplyToParam(t *testing.T) { 40 test, err := tester.NewTest(t) 41 defer test.Close() 42 require.NoError(t, err, "test setup failed") 43 44 _, output, _ := test.RunPorterWith(func(cmd *shx.PreparedCommand) { 45 cmd.Args("lint") 46 cmd.In(filepath.Join(test.RepoRoot, "tests/integration/testdata/bundles/bundle-with-param-apply-lint-error")) 47 }) 48 require.Contains(t, output, "error(porter-101) - Parameter does not apply to action", "parameters being used in actions to which they don't apply should be an error") 49 } 50 51 func TestLint_DependenciesSameName(t *testing.T) { 52 test, err := tester.NewTest(t) 53 defer test.Close() 54 require.NoError(t, err, "test setup failed") 55 56 _, output, _ := test.RunPorterWith(func(cmd *shx.PreparedCommand) { 57 cmd.Args("lint") 58 cmd.In(filepath.Join(test.RepoRoot, "tests/integration/testdata/bundles/bundle-with-samenamedeps-lint-error")) 59 }) 60 require.Contains(t, output, "error(porter-102) - Dependency error", "multiple dependencies with the same name should be an error") 61 }