1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-16 05:16:08 +02:00

apply formatter (#950)

This commit is contained in:
Marcus Holl 2019-11-05 21:51:44 +01:00 committed by Oliver Nocon
parent 5dfc90f386
commit 58128be970
2 changed files with 14 additions and 12 deletions

View File

@ -13,7 +13,6 @@ import (
"github.com/stretchr/testify/assert"
)
type execMockRunner struct {
dir []string
calls []execCall
@ -42,11 +41,11 @@ func (m *execMockRunner) RunExecutable(e string, p ...string) error {
return nil
}
func(m *shellMockRunner) Dir(d string) {
func (m *shellMockRunner) Dir(d string) {
m.dir = d
}
func(m *shellMockRunner) RunShell(s string, c string) error {
func (m *shellMockRunner) RunShell(s string, c string) error {
m.calls = append(m.calls, c)
return nil
}

View File

@ -1,11 +1,11 @@
package cmd
import (
"testing"
"os"
"bytes"
"io"
"github.com/stretchr/testify/assert"
"io"
"os"
"testing"
)
func TestVersion(t *testing.T) {
@ -17,7 +17,6 @@ func TestVersion(t *testing.T) {
assert.Contains(t, result, "tag: \"<n/a>\"")
})
t.Run("versionAndTagSet", func(t *testing.T) {
result := runVersionCommand(t, "16bafe", "v1.2.3")
@ -29,9 +28,9 @@ func TestVersion(t *testing.T) {
func runVersionCommand(t *testing.T, commitID, tag string) string {
orig := os.Stdout
defer func() {os.Stdout = orig}()
defer func() { os.Stdout = orig }()
r,w,e := os.Pipe()
r, w, e := os.Pipe()
if e != nil {
t.Error("Cannot setup pipes.")
}
@ -41,8 +40,12 @@ func runVersionCommand(t *testing.T, commitID, tag string) string {
//
// needs to be set in the free wild by the build process:
// go build -ldflags "-X github.com/SAP/jenkins-library/cmd.GitCommit=${GIT_COMMIT} -X github.com/SAP/jenkins-library/cmd.GitTag=${GIT_TAG}"
if len(commitID) > 0 { GitCommit = commitID; }
if len(tag) > 0 { GitTag = tag }
if len(commitID) > 0 {
GitCommit = commitID
}
if len(tag) > 0 {
GitTag = tag
}
defer func() { GitCommit = ""; GitTag = "" }()
//
//
@ -58,4 +61,4 @@ func runVersionCommand(t *testing.T, commitID, tag string) string {
var buf bytes.Buffer
io.Copy(&buf, r)
return buf.String()
}
}