From eacabadc408d28ed9c823256a2246061d1f02765 Mon Sep 17 00:00:00 2001 From: Andy Grunwald Date: Sat, 9 Dec 2017 22:53:44 +0100 Subject: [PATCH] test: Fix unit test TestArtifactoriesWithInvalidMode The unit test TestArtifactoriesWithInvalidMode was not testing what it should be. The publish parameter was not set and we were testing for skipping instead of error --- pipeline/artifactory/artifactory_test.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pipeline/artifactory/artifactory_test.go b/pipeline/artifactory/artifactory_test.go index 417d59e0e..3525e4b69 100644 --- a/pipeline/artifactory/artifactory_test.go +++ b/pipeline/artifactory/artifactory_test.go @@ -649,16 +649,24 @@ func TestArtifactoriesWithoutSecret(t *testing.T) { } func TestArtifactoriesWithInvalidMode(t *testing.T) { - assert.True(t, pipeline.IsSkip(Pipe{}.Run(context.New(config.Project{ - Artifactories: []config.Artifactory{ - { - Name: "production", - Mode: "does-not-exists", - Target: "http://artifacts.company.com/example-repo-local/{{ .ProjectName }}/{{ .Os }}/{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}", - Username: "deployuser", + // Set secrets for artifactory instances + os.Setenv("ARTIFACTORY_PRODUCTION_SECRET", "deployuser-secret") + defer os.Unsetenv("ARTIFACTORY_PRODUCTION_SECRET") + + var ctx = &context.Context{ + Publish: true, + Config: config.Project{ + Artifactories: []config.Artifactory{ + { + Name: "production", + Mode: "does-not-exists", + Target: "http://artifacts.company.com/example-repo-local/{{ .ProjectName }}/{{ .Os }}/{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}", + Username: "deployuser", + }, }, }, - })))) + } + assert.Error(t, Pipe{}.Run(ctx)) } func TestDefault(t *testing.T) {