MCPcopy
hub / github.com/kptdev/kpt / TestCmd_stdin

Function TestCmd_stdin

internal/cmdget/cmdget_test.go:122–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestCmd_stdin(t *testing.T) {
123 d, err := ioutil.TempDir("", "kpt")
124 if !assert.NoError(t, err) {
125 return
126 }
127 defer os.RemoveAll(d)
128 b := bytes.NewBufferString(`
129apiVersion: apps/v1
130kind: Deployment
131metadata:
132 name: foo1
133 namespace: bar
134`)
135
136 r := cmdget.NewRunner("kpt")
137 r.Command.SetIn(b)
138 r.Command.SetArgs([]string{"-", d, "--pattern", "%k.yaml"})
139 err = r.Command.Execute()
140 if !assert.NoError(t, err) {
141 return
142 }
143 actual, err := ioutil.ReadFile(filepath.Join(d, "deployment.yaml"))
144 if !assert.NoError(t, err) {
145 return
146 }
147 assert.Equal(t, `apiVersion: apps/v1
148kind: Deployment
149metadata:
150 name: foo1
151 namespace: bar
152`, string(actual))
153}
154
155// TestCmd_fail verifies that that command returns an error rather than exiting the process
156func TestCmd_fail(t *testing.T) {

Callers

nothing calls this directly

Calls 2

NewRunnerFunction · 0.92
RemoveAllMethod · 0.45

Tested by

no test coverage detected