(t *testing.T)
| 98 | } |
| 99 | |
| 100 | func TestParseWriteArgs(t *testing.T) { |
| 101 | tests := []struct { |
| 102 | name string |
| 103 | args []string |
| 104 | want writeOptions |
| 105 | err string |
| 106 | }{ |
| 107 | {name: "contents", args: []string{"main/a.txt", "--text", "one\n"}, want: writeOptions{path: "main/a.txt", text: "one\n"}}, |
| 108 | {name: "empty file", args: []string{"empty", "--text", ""}, want: writeOptions{path: "empty"}}, |
| 109 | {name: "missing text", args: []string{"empty"}, err: "pass --text with the file contents"}, |
| 110 | {name: "outside workspace", args: []string{"../escape", "--text", "x"}, err: "pass a file path relative to the Git workspace"}, |
| 111 | {name: "missing path", args: []string{"--text", "x"}, err: "pass a file path relative to the Git workspace"}, |
| 112 | } |
| 113 | for _, tt := range tests { |
| 114 | t.Run(tt.name, func(t *testing.T) { |
| 115 | got, err := parseWriteArgs(tt.args) |
| 116 | if tt.err != "" { |
| 117 | require.EqualError(t, err, tt.err) |
| 118 | return |
| 119 | } |
| 120 | require.NoError(t, err) |
| 121 | assert.Equal(t, tt.want, got) |
| 122 | }) |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | func TestCmdWrite(t *testing.T) { |
| 127 | tests := []struct { |
nothing calls this directly
no test coverage detected