MCPcopy
hub / github.com/cli/cli / Test_Write

Function Test_Write

pkg/cmd/pr/create/regexp_writer_test.go:12–160  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func Test_Write(t *testing.T) {
13 type input struct {
14 in []string
15 re *regexp.Regexp
16 repl string
17 }
18 type output struct {
19 wantsErr bool
20 out string
21 length int
22 }
23 tests := []struct {
24 name string
25 input input
26 output output
27 }{
28 {
29 name: "single line input",
30 input: input{
31 in: []string{"some input line that has wrong information"},
32 re: regexp.MustCompile("wrong"),
33 repl: "right",
34 },
35 output: output{
36 wantsErr: false,
37 out: "some input line that has right information",
38 length: 42,
39 },
40 },
41 {
42 name: "multiple line input",
43 input: input{
44 in: []string{"multiple lines\nin this\ninput lines"},
45 re: regexp.MustCompile("lines"),
46 repl: "tests",
47 },
48 output: output{
49 wantsErr: false,
50 out: "multiple tests\nin this\ninput tests",
51 length: 34,
52 },
53 },
54 {
55 name: "no matches",
56 input: input{
57 in: []string{"this line has no matches"},
58 re: regexp.MustCompile("wrong"),
59 repl: "right",
60 },
61 output: output{
62 wantsErr: false,
63 out: "this line has no matches",
64 length: 24,
65 },
66 },
67 {
68 name: "no output",
69 input: input{

Callers

nothing calls this directly

Calls 7

WriteMethod · 0.95
FlushMethod · 0.95
NewRegexpWriterFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected