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

Function TestShellCatEnforce

pkg/devspace/pipeline/engine/engine_test.go:77–107  ·  view source on GitHub ↗

this test forces the cat implementation to execute

(t *testing.T)

Source from the content-addressed store, hash-verified

75
76// this test forces the cat implementation to execute
77func TestShellCatEnforce(t *testing.T) {
78 file, err := os.CreateTemp(".", "testFile")
79 if err != nil {
80 t.Fatal(err)
81 }
82 defer os.Remove(file.Name())
83
84 if _, err = file.WriteString("Hello DevSpace!"); err != nil {
85 t.Fatalf("Unable to write to temporary file %v", err)
86 }
87
88 testCases := []testCaseShell{
89 {
90 command: "cat " + filepath.ToSlash(file.Name()),
91 expectedOutput: "Hello DevSpace!",
92 },
93 {
94 command: "echo 123 | cat",
95 expectedOutput: "123\n",
96 },
97 }
98
99 for _, testCase := range testCases {
100 stdout := &bytes.Buffer{}
101 err := ExecuteSimpleShellCommand(context.Background(), ".", expand.ListEnviron(os.Environ()...), stdout, nil, nil, testCase.command)
102 if err != nil {
103 t.Fatal(err)
104 }
105 assert.Equal(t, stdout.String(), testCase.expectedOutput)
106 }
107}
108
109func TestKubectlDownload(t *testing.T) {
110 stdout := &bytes.Buffer{}

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