From 9a02d310825a12cec4520942c57e2f68ab3fd89e Mon Sep 17 00:00:00 2001 From: Neel Dalsania Date: Mon, 11 Sep 2023 20:29:29 +0530 Subject: [PATCH] fix case of html report not generating in pytest with failing tests (#1383) --- airflow/docker_image.go | 2 +- airflow/docker_image_test.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/airflow/docker_image.go b/airflow/docker_image.go index d4e558569..1b54e1585 100644 --- a/airflow/docker_image.go +++ b/airflow/docker_image.go @@ -151,7 +151,7 @@ func (d *DockerImage) Pytest(pytestFile, airflowHome, envFile, testHomeDirectory // start pytest container docErr = cmdExec(dockerCommand, stdout, stderr, []string{"start", "astro-pytest", "-a"}...) if docErr != nil { - return "", docErr + log.Debugf("Error starting pytest container: %s", docErr.Error()) } // get exit code args = []string{ diff --git a/airflow/docker_image_test.go b/airflow/docker_image_test.go index d3dfea85c..9f850519b 100644 --- a/airflow/docker_image_test.go +++ b/airflow/docker_image_test.go @@ -131,12 +131,16 @@ func TestDockerImagePytest(t *testing.T) { switch { case args[0] == "start": return errMock + case args[0] == "inspect": + stdout.Write([]byte(`exit code 1`)) // making sure exit code is captured properly + return nil default: return nil } } - _, err = handler.Pytest("", "", "", "", []string{}, true, options) + out, err := handler.Pytest("", "", "", "", []string{}, true, options) assert.Error(t, err) + assert.Equal(t, out, "exit code 1") }) t.Run("copy error", func(t *testing.T) {