(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestNewCmdRun(t *testing.T) { |
| 27 | tests := []struct { |
| 28 | name string |
| 29 | cli string |
| 30 | tty bool |
| 31 | wants RunOptions |
| 32 | wantsErr bool |
| 33 | errMsg string |
| 34 | stdin string |
| 35 | }{ |
| 36 | { |
| 37 | name: "blank nontty", |
| 38 | wantsErr: true, |
| 39 | errMsg: "workflow ID, name, or filename required when not running interactively", |
| 40 | }, |
| 41 | { |
| 42 | name: "blank tty", |
| 43 | tty: true, |
| 44 | wants: RunOptions{ |
| 45 | Prompt: true, |
| 46 | }, |
| 47 | }, |
| 48 | { |
| 49 | name: "ref flag", |
| 50 | tty: true, |
| 51 | cli: "--ref 12345abc", |
| 52 | wants: RunOptions{ |
| 53 | Prompt: true, |
| 54 | Ref: "12345abc", |
| 55 | }, |
| 56 | }, |
| 57 | { |
| 58 | name: "both STDIN and input fields", |
| 59 | stdin: "some json", |
| 60 | cli: "workflow.yml -fhey=there --json", |
| 61 | errMsg: "only one of STDIN or -f/-F can be passed", |
| 62 | wantsErr: true, |
| 63 | }, |
| 64 | { |
| 65 | name: "-f args", |
| 66 | tty: true, |
| 67 | cli: `workflow.yml -fhey=there -fname="dana scully"`, |
| 68 | wants: RunOptions{ |
| 69 | Selector: "workflow.yml", |
| 70 | RawFields: []string{"hey=there", "name=dana scully"}, |
| 71 | }, |
| 72 | }, |
| 73 | { |
| 74 | name: "-F args", |
| 75 | tty: true, |
| 76 | cli: `workflow.yml -Fhey=there -Fname="dana scully" -Ffile=@cool.txt`, |
| 77 | wants: RunOptions{ |
| 78 | Selector: "workflow.yml", |
| 79 | MagicFields: []string{"hey=there", "name=dana scully", "file=@cool.txt"}, |
| 80 | }, |
| 81 | }, |
| 82 | { |
| 83 | name: "-F/-f arg mix", |
nothing calls this directly
no test coverage detected