This commit is contained in:
parent
143ca8d555
commit
e1b53f8bea
2 changed files with 60 additions and 0 deletions
|
|
@ -60,3 +60,27 @@ func TestOS_Exec(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOS_Bang(t *testing.T) {
|
||||
tests := []struct {
|
||||
descr string
|
||||
eval string
|
||||
want any
|
||||
}{
|
||||
{descr: "run command 1", eval: `os:! "echo 'hello, world'"`, want: "hello, world\n"},
|
||||
{descr: "run command 2", eval: `os:! "date +%Y%m%d"`, want: time.Now().Format("20060102") + "\n"},
|
||||
{descr: "run command 3", eval: `os:! "tr [a-z] [A-Z]" "hello"`, want: "HELLO"},
|
||||
{descr: "run command 4", eval: `os:! "tr -d e" "hello"`, want: "hllo"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.descr, func(t *testing.T) {
|
||||
inst := ucl.New(
|
||||
ucl.WithModule(builtins.OS()),
|
||||
)
|
||||
res, err := inst.EvalString(context.Background(), tt.eval)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tt.want, res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue