github.com/drone/runner-go@v1.12.0/shell/bash/bash_test.go (about) 1 // Copyright 2019 Drone.IO Inc. All rights reserved. 2 // Use of this source code is governed by the Polyform License 3 // that can be found in the LICENSE file. 4 5 package bash 6 7 import ( 8 "reflect" 9 "testing" 10 ) 11 12 func TestCommands(t *testing.T) { 13 cmd, args := Command() 14 { 15 got, want := cmd, "/bin/sh" 16 if !reflect.DeepEqual(got, want) { 17 t.Errorf("Want command %v, got %v", want, got) 18 } 19 } 20 { 21 got, want := args, []string{"-e"} 22 if !reflect.DeepEqual(got, want) { 23 t.Errorf("Want command %v, got %v", want, got) 24 } 25 } 26 } 27 28 func TestScript(t *testing.T) { 29 got, want := Script([]string{"go build", "go test"}), exampleScript 30 if got != want { 31 t.Errorf("Want %q, got %q", want, got) 32 } 33 } 34 35 func TestSilentScript(t *testing.T) { 36 got, want := SilentScript([]string{"go build", "go test"}), exampleSilentScript 37 if got != want { 38 t.Errorf("Want %q, got %q", want, got) 39 } 40 } 41 42 var exampleScript = ` 43 set -e 44 45 echo + "go build" 46 go build 47 48 echo + "go test" 49 go test 50 ` 51 52 var exampleSilentScript = ` 53 set -e 54 55 go build 56 57 go test 58 `