<commit_before>package main

import (
	"os"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestRunPipelines(t *testing.T) {

	t.Run("ReturnsResultWithoutErrorsWhenManifestHasNoPipelines", func(t *testing.T) {

		manifest := new(estafetteManifest)
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.False(t, result.HasErrors())
	})

	t.Run("ReturnsResultWithInnerResultForEachPipelineInManifest", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 0"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.Equal(t, 1, len(result.PipelineResults))
	})

	t.Run("ReturnsResultWithoutErrorsWhenPipelinesSucceeded", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 0"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.False(t, result.HasErrors())
	})

	t.Run("ReturnsResultWithSucceededPipelineResultWhenPipelinesSucceeded", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 0"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.Equal(t, "SUCCEEDED", result.PipelineResults[0].Status)
	})

	t.Run("ReturnsResultWithErrorsWhenPipelinesFailed", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 1"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.Equal(t, "/Users/jorrit/WorkingCopies/go/src/github.com/estafette/estafette-ci-builder", dir)

		assert.True(t, result.HasErrors())
	})

	t.Run("ReturnsResultWithFailedPipelineResultWhenPipelinesFailed", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 1"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.Equal(t, "FAILED", result.PipelineResults[0].Status)
	})

	t.Run("ReturnsResultWithoutErrorsWhenPipelinesSkipped", func(t *testing.T) {
<commit_msg>remove local 'debug' test<commit_after>package main

import (
	"os"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestRunPipelines(t *testing.T) {

	t.Run("ReturnsResultWithoutErrorsWhenManifestHasNoPipelines", func(t *testing.T) {

		manifest := new(estafetteManifest)
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.False(t, result.HasErrors())
	})

	t.Run("ReturnsResultWithInnerResultForEachPipelineInManifest", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 0"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.Equal(t, 1, len(result.PipelineResults))
	})

	t.Run("ReturnsResultWithoutErrorsWhenPipelinesSucceeded", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 0"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.False(t, result.HasErrors())
	})

	t.Run("ReturnsResultWithSucceededPipelineResultWhenPipelinesSucceeded", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 0"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.Equal(t, "SUCCEEDED", result.PipelineResults[0].Status)
	})

	t.Run("ReturnsResultWithErrorsWhenPipelinesFailed", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 1"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.True(t, result.HasErrors())
	})

	t.Run("ReturnsResultWithFailedPipelineResultWhenPipelinesFailed", func(t *testing.T) {

		manifest := new(estafetteManifest)
		manifest.Pipelines = append(manifest.Pipelines, &estafettePipeline{Name: "TestStep", ContainerImage: "busybox:latest", Shell: "/bin/sh", WorkingDirectory: "/estafette-work", Commands: []string{"exit 1"}, When: "status == 'succeeded'"})
		envvars := map[string]string{}
		dir, _ := os.Getwd()

		// act
		result := runPipelines(*manifest, dir, envvars)

		assert.Equal(t, "FAILED", result.PipelineResults[0].Status)
	})

	t.Run("ReturnsResultWithoutErrorsWhenPipelinesSkipped", func(t *testing.T) {

{'fraction_non_alphanumeric': 0.16661505109941158, 'fraction_numerical': 0.0024775472282440383, 'mean_word_length': 5.856687898089172, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6054016', 'n_tokens_mistral': 2371, 'n_tokens_neox': 2173, 'n_words': 388}