MCPcopy Create free account
hub / github.com/cli/cli / TestReadContent

Function TestReadContent

pkg/cmd/issue/artifact/shared/content_test.go:15–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestReadContent(t *testing.T) {
16 // The first bytes of a PNG image.
17 const pngBytes = "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00@\x00\x00\x00(\x08\x02\x00\x00\x00"
18
19 tests := []struct {
20 name string
21 files map[string]string
22 symlinks map[string]string
23 path string
24 stdin string
25 want string
26 wantDir string
27 wantErr string
28 wantErrIs error
29 }{
30 {
31 name: "a text file",
32 files: map[string]string{"signin-plan.md": "# Sign-in plan\n\n1. Register the callback URL.\n"},
33 path: "signin-plan.md",
34 want: "# Sign-in plan\n\n1. Register the callback URL.\n",
35 wantDir: ".",
36 },
37 {
38 name: "a file in another directory",
39 files: map[string]string{"docs/signin-plan.md": "# Sign-in plan\n"},
40 path: "docs/signin-plan.md",
41 want: "# Sign-in plan\n",
42 wantDir: "docs",
43 },
44 {
45 name: "text in any language",
46 files: map[string]string{"memo.md": "# メモ\n\nラテアートの練習。\n"},
47 path: "memo.md",
48 want: "# メモ\n\nラテアートの練習。\n",
49 wantDir: ".",
50 },
51 {
52 name: "a symlink is followed",
53 files: map[string]string{"outside.md": "# Sign-in plan\n"},
54 symlinks: map[string]string{"signin-plan.md": "outside.md"},
55 path: "signin-plan.md",
56 want: "# Sign-in plan\n",
57 wantDir: ".",
58 },
59 {
60 name: "standard input has no directory",
61 path: "-",
62 stdin: "# OAuth research\n",
63 want: "# OAuth research\n",
64 wantDir: "",
65 },
66 {
67 name: "standard input is only read for -",
68 files: map[string]string{"signin-plan.md": "# Sign-in plan\n"},
69 path: "signin-plan.md",
70 stdin: "# OAuth research\n",
71 want: "# Sign-in plan\n",
72 wantDir: ".",

Callers

nothing calls this directly

Calls 6

ReadContentFunction · 0.85
MkdirAllMethod · 0.80
WriteFileMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected