MCPcopy Index your code
hub / github.com/cli/cli / TestContent_tableTests

Function TestContent_tableTests

internal/licenses/licenses_test.go:19–160  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17}
18
19func TestContent_tableTests(t *testing.T) {
20 tests := []struct {
21 name string
22 fsys fstest.MapFS
23 expected string
24 }{
25 {
26 name: "report only",
27 fsys: fstest.MapFS{
28 "embed/os-arch/PLACEHOLDER": &fstest.MapFile{}, // Checked-in placeholder, so it's always there.
29 "embed/os-arch/report.txt": &fstest.MapFile{Data: []byte("dep1 (v1.0.0) - MIT - https://example.com\n")},
30 },
31 expected: heredoc.Doc(`
32 dep1 (v1.0.0) - MIT - https://example.com
33
34 `),
35 },
36 {
37 name: "empty third-party dir",
38 fsys: fstest.MapFS{
39 "embed/os-arch/PLACEHOLDER": &fstest.MapFile{}, // Checked-in placeholder, so it's always there.
40 "embed/os-arch/report.txt": &fstest.MapFile{Data: []byte("dep1 (v1.0.0) - MIT - https://example.com\n")},
41 "embed/os-arch/third-party": &fstest.MapFile{Data: []byte{}, Mode: fs.ModeDir},
42 },
43 expected: heredoc.Doc(`
44 dep1 (v1.0.0) - MIT - https://example.com
45
46 `),
47 },
48 {
49 name: "unknown file at root ignored",
50 fsys: fstest.MapFS{
51 "embed/os-arch/PLACEHOLDER": &fstest.MapFile{}, // Checked-in placeholder, so it's always there.
52 "embed/os-arch/report.txt": &fstest.MapFile{Data: []byte("dep1 (v1.0.0) - MIT - https://example.com\n")},
53 "embed/os-arch/unknown": &fstest.MapFile{
54 Data: []byte("MIT License\n\nCopyright (c) 2024"),
55 },
56 },
57 expected: heredoc.Doc(`
58 dep1 (v1.0.0) - MIT - https://example.com
59
60 `),
61 },
62 {
63 name: "unknown directory at root ignored",
64 fsys: fstest.MapFS{
65 "embed/os-arch/PLACEHOLDER": &fstest.MapFile{}, // Checked-in placeholder, so it's always there.
66 "embed/os-arch/report.txt": &fstest.MapFile{Data: []byte("dep1 (v1.0.0) - MIT - https://example.com\n")},
67 "embed/os-arch/unknown/example.com/mod/LICENSE": &fstest.MapFile{
68 Data: []byte("MIT License\n\nCopyright (c) 2024"),
69 },
70 },
71 expected: heredoc.Doc(`
72 dep1 (v1.0.0) - MIT - https://example.com
73
74 `),
75 },
76 {

Callers

nothing calls this directly

Calls 3

contentFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected