grim/convey
Clone
Summary
Browse
Changes
Graph
Move plans to the runtime package
2021-12-23, Gary Kramlich
178aec6c4f86
Move plans to the runtime package
//go:build !windows
package
script
import
(
"testing"
"github.com/stretchr/testify/assert"
"keep.imfreedom.org/grim/convey/yaml"
)
func
TestShellDefaults
(
t
*
testing
.
T
)
{
s
:=
&
Shell
{
Filename
:
"/dev/null"
,
}
s
.
Valid
()
assert
.
Equal
(
t
,
s
.
Shell
,
"/bin/sh"
)
}
func
TestShellCommands
(
t
*
testing
.
T
)
{
s
:=
&
Shell
{
Commands
:
yaml
.
StringOrSlice
{
"uptime"
},
}
assert
.
NoError
(
t
,
s
.
Valid
())
}
func
TestShellFilename
(
t
*
testing
.
T
)
{
s
:=
&
Shell
{
Filename
:
"/dev/null"
,
}
assert
.
NoError
(
t
,
s
.
Valid
())
}
func
TestShellNeitherFilenameNorCommands
(
t
*
testing
.
T
)
{
s
:=
&
Shell
{}
assert
.
ErrorIs
(
t
,
s
.
Valid
(),
ErrNoCommandsOrFilename
)
}
func
TestShellBothFilenameAndCommands
(
t
*
testing
.
T
)
{
s
:=
&
Shell
{
Commands
:
yaml
.
StringOrSlice
{
"uptime"
},
Filename
:
"/dev/null"
,
}
assert
.
ErrorIs
(
t
,
s
.
Valid
(),
ErrOnlyFilenameOrCommands
)
}