Skip to content

Commit

Permalink
Merge pull request #7375 from deads2k/fix-symlink
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Feb 17, 2016
2 parents f12d468 + 1cad791 commit cffae05
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 0 additions & 1 deletion pkg/cmd/cli/secrets/bsFixtures/dir/symbolic

This file was deleted.

21 changes: 18 additions & 3 deletions pkg/cmd/cli/secrets/new_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package secrets

import (
"bytes"
"io/ioutil"
"os"
"testing"

kapi "k8s.io/kubernetes/pkg/api"
Expand Down Expand Up @@ -40,11 +42,16 @@ func TestValidate(t *testing.T) {
}

func TestCreateSecret(t *testing.T) {
os.Symlink(".", "./bsFixtures/dir/symbolic")
defer os.Remove("./bsFixtures/dir/symbolic")

tests := []struct {
testName string
args []string
expErr bool
quiet bool

errStreamContent string
}{
{
testName: "validSources",
Expand All @@ -70,9 +77,9 @@ func TestCreateSecret(t *testing.T) {
quiet: true,
},
{
testName: "testQuietFalse",
args: []string{"testSecret", "./bsFixtures/dir"},
expErr: true, // "Skipping resource <resource path>"
testName: "testQuietFalse",
args: []string{"testSecret", "./bsFixtures/dir"},
errStreamContent: "Skipping resource bsFixtures/dir/symbolic\n",
},
{
testName: "testNamedKeys",
Expand Down Expand Up @@ -116,7 +123,9 @@ func TestCreateSecret(t *testing.T) {
},
}
for _, test := range tests {
errStream := &bytes.Buffer{}
options := NewCreateSecretOptions()
options.Stderr = errStream
options.Complete(test.args, nil)
options.Quiet = test.quiet

Expand All @@ -128,6 +137,12 @@ func TestCreateSecret(t *testing.T) {
if err != nil && !test.expErr {
t.Errorf("%s: unexpected error: %s", test.testName, err)
}
if err == nil && test.expErr {
t.Errorf("%s: missing expected error", test.testName)
}
if string(errStream.Bytes()) != test.errStreamContent {
t.Errorf("%s: expected %s, got %v", test.testName, test.errStreamContent, string(errStream.Bytes()))
}
}
}

Expand Down

0 comments on commit cffae05

Please sign in to comment.