diff --git a/cli/options_test.go b/cli/options_test.go index 31edf9b9..a3deb8ae 100644 --- a/cli/options_test.go +++ b/cli/options_test.go @@ -242,6 +242,35 @@ func TestProjectComposefilesFromWorkingDir(t *testing.T) { }) } +func TestProjectComposefilesFromStdin(t *testing.T) { + composeData := ` +services: + simple: + image: nginx +` + r, w, _ := os.Pipe() + defer func() { + os.Stdin = r + }() + + w.WriteString(composeData) + w.Close() + + os.Stdin = r + + opts, err := NewProjectOptions( + []string{ + "-", + }, WithName("my_project"), + ) + assert.NilError(t, err) + p, err := opts.LoadProject(context.TODO()) + assert.NilError(t, err) + service, err := p.GetService("simple") + assert.NilError(t, err) + assert.Equal(t, service.Image, "nginx") +} + func TestProjectWithDotEnv(t *testing.T) { wd, err := os.Getwd() assert.NilError(t, err)