MCPcopy Index your code
hub / github.com/devspace-sh/devspace / TestShellCat

Function TestShellCat

pkg/devspace/pipeline/engine/engine_test.go:20–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func TestShellCat(t *testing.T) {
21 file, err := os.CreateTemp(".", "testFile")
22 if err != nil {
23 t.Fatal(err)
24 }
25 defer os.Remove(file.Name())
26
27 if _, err = file.WriteString("Hello DevSpace!"); err != nil {
28 t.Fatalf("Unable to write to temporary file %v", err)
29 }
30
31 testCases := []testCaseShell{
32 {
33 command: "cat " + filepath.ToSlash(file.Name()),
34 expectedOutput: "Hello DevSpace!",
35 },
36 {
37 command: "echo 123 | cat",
38 expectedOutput: "123\n",
39 },
40 }
41
42 for _, testCase := range testCases {
43 stdout := &bytes.Buffer{}
44 err := ExecuteSimpleShellCommand(context.Background(), ".", expand.ListEnviron(os.Environ()...), stdout, nil, nil, testCase.command)
45 if err != nil {
46 t.Fatal(err)
47 }
48 assert.Equal(t, stdout.String(), testCase.expectedOutput)
49 }
50}
51
52func TestShellCatError(t *testing.T) {
53 testCases := []testCaseShell{

Callers

nothing calls this directly

Calls 9

StringMethod · 0.95
EqualMethod · 0.80
RemoveMethod · 0.65
NameMethod · 0.65
WriteStringMethod · 0.65
EnvironMethod · 0.65
FatalMethod · 0.45
FatalfMethod · 0.45

Tested by

no test coverage detected