MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestCommandsString

Function TestCommandsString

internal/devbox/shellcmd/command_test.go:102–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestCommandsString(t *testing.T) {
103 tests := []struct {
104 jsonIn string
105 want string
106 }{
107 {
108 jsonIn: `null`,
109 want: "",
110 },
111 {
112 jsonIn: `[]`,
113 want: "",
114 },
115 {
116 jsonIn: `[""]`,
117 want: "",
118 },
119 {
120 jsonIn: `["\n"]`,
121 want: "\n",
122 },
123 {
124 jsonIn: `["echo 'line1'\necho 'line2'"]`,
125 want: "echo 'line1'\necho 'line2'",
126 },
127 {
128 jsonIn: `["echo 'line1'", "echo 'line2'"]`,
129 want: "echo 'line1'\necho 'line2'",
130 },
131 {
132 jsonIn: `["echo 'line1'\n\necho 'line2'"]`,
133 want: "echo 'line1'\n\necho 'line2'",
134 },
135 {
136 jsonIn: `["echo 'line1'", "", "echo 'line2'"]`,
137 want: "echo 'line1'\n\necho 'line2'",
138 },
139 }
140 for _, test := range tests {
141 t.Run(test.jsonIn, func(t *testing.T) {
142 got := Commands{}
143 if err := json.Unmarshal([]byte(test.jsonIn), &got); err != nil {
144 t.Fatal("Got error unmarshalling test input:", err)
145 }
146 if got.String() != test.want {
147 t.Errorf("got.String() != want\ngot: %q\nwant: %q",
148 got.String(), test.want)
149 }
150 })
151 }
152}
153
154func ExampleCommands_AppendScript() {
155 shCmds := Commands{}

Callers

nothing calls this directly

Calls 2

StringMethod · 0.95
RunMethod · 0.65

Tested by

no test coverage detected