From 0e87616cc763e8d39e60b5c69ce374095ac9303a Mon Sep 17 00:00:00 2001 From: Suleiman Dibirov Date: Wed, 30 Oct 2024 07:30:23 +0200 Subject: [PATCH] Add test to options_test.go Signed-off-by: Suleiman Dibirov --- cli/options_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cli/options_test.go b/cli/options_test.go index 31edf9b9..5dbba5d6 100644 --- a/cli/options_test.go +++ b/cli/options_test.go @@ -242,6 +242,36 @@ func TestProjectComposefilesFromWorkingDir(t *testing.T) { }) } +func TestProjectComposefilesFromStdin(t *testing.T) { + composeData := ` +services: + simple: + image: nginx +` + originalStdin := os.Stdin + r, w, _ := os.Pipe() + defer func() { + os.Stdin = originalStdin + }() + + 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)