project_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package compose
  2. import (
  3. "os"
  4. "testing"
  5. . "github.com/onsi/gomega"
  6. "github.com/stretchr/testify/suite"
  7. )
  8. type ComposeTest struct {
  9. suite.Suite
  10. }
  11. func (suite *ComposeTest) TestParseComposeFile() {
  12. files := []string{"../tests/composefiles/aci-demo/aci_demo_port.yaml"}
  13. config, err := parseConfigs(files)
  14. Expect(err).To(BeNil())
  15. services := config[0].Config["services"].(map[string]interface{})
  16. Expect(len(services)).To(Equal(3))
  17. }
  18. func (suite *ComposeTest) TestParseComposeStdin() {
  19. files := []string{"-"}
  20. f, err := os.Open("../tests/composefiles/aci-demo/aci_demo_port.yaml")
  21. Expect(err).To(BeNil())
  22. defer func() {
  23. err := f.Close()
  24. Expect(err).To(BeNil())
  25. }()
  26. oldStdin := os.Stdin
  27. defer func() { os.Stdin = oldStdin }() // Restore original Stdin
  28. os.Stdin = f
  29. config, err := parseConfigs(files)
  30. Expect(err).To(BeNil())
  31. services := config[0].Config["services"].(map[string]interface{})
  32. Expect(len(services)).To(Equal(3))
  33. }
  34. func TestComposeProject(t *testing.T) {
  35. RegisterTestingT(t)
  36. suite.Run(t, new(ComposeTest))
  37. }