Added os bang
All checks were successful
Build / build (push) Successful in 3m42s

This commit is contained in:
Leon Mika 2026-09-08 20:36:39 +10:00
parent 143ca8d555
commit e1b53f8bea
2 changed files with 60 additions and 0 deletions

View file

@ -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)
})
}
}