(t *testing.T)
| 258 | } |
| 259 | |
| 260 | func TestResolveInputFlags_StripBOMFile(t *testing.T) { |
| 261 | dir := t.TempDir() |
| 262 | cmdutil.TestChdir(t, dir) |
| 263 | |
| 264 | // A JSON operations file saved with a BOM would otherwise fail json.Unmarshal |
| 265 | // with "invalid character 'ï'". |
| 266 | if err := os.WriteFile("ops.json", []byte("\uFEFF[{\"shortcut\":\"+cells-set\"}]"), 0644); err != nil { |
| 267 | t.Fatal(err) |
| 268 | } |
| 269 | rctx := newTestRuntimeWithStdin(map[string]string{"operations": "@ops.json"}, "") |
| 270 | flags := []Flag{{Name: "operations", Input: []string{File, Stdin}}} |
| 271 | |
| 272 | if err := resolveInputFlags(rctx, flags); err != nil { |
| 273 | t.Fatalf("unexpected error: %v", err) |
| 274 | } |
| 275 | if got := rctx.Str("operations"); got != "[{\"shortcut\":\"+cells-set\"}]" { |
| 276 | t.Errorf("leading BOM not stripped from file, got %q", got) |
| 277 | } |
| 278 | } |
nothing calls this directly
no test coverage detected