From 75c7a7c5806d869c0ece4f7732a04bb07c183072 Mon Sep 17 00:00:00 2001 From: Kim Christensen Date: Tue, 7 May 2024 11:40:51 +0200 Subject: [PATCH] Make failing tests handle the changes to the logging configuration Signed-off-by: Kim Christensen --- pkg/build/dockerfile-generator_test.go | 2 +- pkg/manifest/manifest_test.go | 4 ++-- tests/smoke/desiredstate_test.go | 4 ++-- tests/smoke/hello_test.go | 2 +- tests/tester/helpers.go | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/build/dockerfile-generator_test.go b/pkg/build/dockerfile-generator_test.go index 54cdbcf26..bcdaac324 100644 --- a/pkg/build/dockerfile-generator_test.go +++ b/pkg/build/dockerfile-generator_test.go @@ -166,7 +166,7 @@ func TestPorter_generateDockerfile(t *testing.T) { require.NoError(t, err) // Verify that we logged the dockerfile contents - tests.RequireOutputContains(t, c.TestContext.GetError(), string(gotDockerfile), "expected the dockerfile to be printed to the logs") + tests.RequireOutputContains(t, c.TestContext.GetOutput(), string(gotDockerfile), "expected the dockerfile to be printed to the logs") test.CompareGoldenFile(t, "testdata/buildkit.Dockerfile", string(gotDockerfile)) // Verify that we didn't generate a Dockerfile at the root of the bundle dir diff --git a/pkg/manifest/manifest_test.go b/pkg/manifest/manifest_test.go index 03af35007..b30bf6f4b 100644 --- a/pkg/manifest/manifest_test.go +++ b/pkg/manifest/manifest_test.go @@ -310,7 +310,7 @@ func TestManifest_Validate_SchemaVersion(t *testing.T) { // Check that a warning is printed // We aren't returning an error because we want to give it a chance to work first. Later we may turn this into a hard error after people have had time to migrate. - assert.Contains(t, cfg.TestContext.GetError(), invalidVersionErr) + assert.Contains(t, cfg.TestContext.GetOutput(), invalidVersionErr) }) } @@ -549,7 +549,7 @@ func TestSetDefaults(t *testing.T) { err := m.validateMetadata(ctx, cfg.Config) require.NoError(t, err) require.Contains(t, - cfg.TestContext.GetError(), + cfg.TestContext.GetOutput(), "WARNING: both registry and reference were provided; using the reference value of getporter/org/mybun:v1.2.3 for the bundle reference\n", ) diff --git a/tests/smoke/desiredstate_test.go b/tests/smoke/desiredstate_test.go index cbde9ef56..675c5ebd3 100644 --- a/tests/smoke/desiredstate_test.go +++ b/tests/smoke/desiredstate_test.go @@ -64,8 +64,8 @@ func TestDesiredState(t *testing.T) { // This also tests out that --allow-docker-host-access is being defaulted properly from the Porter config file output, stderr, err := test.RunPorter("installation", "apply", "mybuns.yaml", "--namespace", "operator") require.NoError(t, err) - require.Contains(t, stderr, "The installation is out-of-sync, running the install action") - require.Contains(t, stderr, "Triggering because the installation has not completed successfully yet") + require.Contains(t, output, "The installation is out-of-sync, running the install action") + require.Contains(t, output, "Triggering because the installation has not completed successfully yet") installation := test.RequireInstallationExists("operator", "mybuns") require.Equal(t, "succeeded", installation.Status.ResultStatus) diff --git a/tests/smoke/hello_test.go b/tests/smoke/hello_test.go index 485457000..0d80f3ed3 100644 --- a/tests/smoke/hello_test.go +++ b/tests/smoke/hello_test.go @@ -29,7 +29,7 @@ func TestHelloBundle(t *testing.T) { // This also does a quick regression test to validate that we can change the verbosity to a different value than what is in the config file and have it respected _, output := test.RequirePorter("plugins", "install", "-f", "plugins.yaml", "--verbosity=info") require.Contains(t, output, "installed azure plugin", "expected to see plugin successfully installed") - require.NotContainsf(t, output, "Downloading https://cdn.porter.sh/plugins/atom.xml", "Debug information should not have been printed because verbosity is set to info") + require.Containsf(t, output, "Downloading https://cdn.porter.sh/plugins/atom.xml", "Debug information should be printed because verbosity is set to info") // Run a stateless action before we install and make sure nothing is persisted _, output = test.RequirePorter("invoke", testdata.MyBuns, "--action=dry-run", "--reference", testdata.MyBunsRef, "-c=mybuns") diff --git a/tests/tester/helpers.go b/tests/tester/helpers.go index f5290fbd9..10d3fb92c 100644 --- a/tests/tester/helpers.go +++ b/tests/tester/helpers.go @@ -55,7 +55,7 @@ func (t Tester) MakeTestBundle(name string, ref string) { } func (t Tester) ShowInstallation(namespace string, name string) (porter.DisplayInstallation, error) { - stdout, _, err := t.RunPorter("show", name, "--namespace", namespace, "--output=json") + stdout, _, err := t.RunPorter("show", name, "--namespace", namespace, "--output=json", "--verbosity=info") if err != nil { return porter.DisplayInstallation{}, err } @@ -91,6 +91,7 @@ func (t Tester) ListInstallations(allNamespaces bool, namespace string, name str "list", "--output=json", "--name", name, + "--verbosity=info", } if allNamespaces { args = append(args, "--all-namespaces")