MCPcopy
hub / github.com/go-task/task / TestCmdParse

Function TestCmdParse

taskfile/ast/taskfile_test.go:13–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestCmdParse(t *testing.T) {
14 t.Parallel()
15
16 const (
17 yamlCmd = `echo "a string command"`
18 yamlDep = `"task-name"`
19 yamlTaskCall = `
20task: another-task
21vars:
22 PARAM1: VALUE1
23 PARAM2: VALUE2
24`
25 yamlDeferredCall = `defer: { task: some_task, vars: { PARAM1: "var" } }`
26 yamlDeferredCmd = `defer: echo 'test'`
27 )
28 tests := []struct {
29 content string
30 v any
31 expected any
32 }{
33 {
34 yamlCmd,
35 &ast.Cmd{},
36 &ast.Cmd{Cmd: `echo "a string command"`},
37 },
38 {
39 yamlTaskCall,
40 &ast.Cmd{},
41 &ast.Cmd{
42 Task: "another-task",
43 Vars: ast.NewVars(
44 &ast.VarElement{
45 Key: "PARAM1",
46 Value: ast.Var{
47 Value: "VALUE1",
48 },
49 },
50 &ast.VarElement{
51 Key: "PARAM2",
52 Value: ast.Var{
53 Value: "VALUE2",
54 },
55 },
56 ),
57 },
58 },
59 {
60 yamlDeferredCmd,
61 &ast.Cmd{},
62 &ast.Cmd{Cmd: "echo 'test'", Defer: true},
63 },
64 {
65 yamlDeferredCall,
66 &ast.Cmd{},
67 &ast.Cmd{
68 Task: "some_task",
69 Vars: ast.NewVars(
70 &ast.VarElement{

Callers

nothing calls this directly

Calls 1

NewVarsFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…