(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestCmdParse(t *testing.T) { |
| 14 | t.Parallel() |
| 15 | |
| 16 | const ( |
| 17 | yamlCmd = `echo "a string command"` |
| 18 | yamlDep = `"task-name"` |
| 19 | yamlTaskCall = ` |
| 20 | task: another-task |
| 21 | vars: |
| 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{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…