MCPcopy
hub / github.com/larksuite/cli / TestResolveInputFlags_StripBOMFile

Function TestResolveInputFlags_StripBOMFile

shortcuts/common/runner_input_test.go:260–278  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

258}
259
260func 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}

Callers

nothing calls this directly

Calls 5

TestChdirFunction · 0.92
newTestRuntimeWithStdinFunction · 0.85
resolveInputFlagsFunction · 0.85
WriteFileMethod · 0.65
StrMethod · 0.65

Tested by

no test coverage detected