Fix envfile detection

+ The envfiles were not added!

see #8

TODO: what are the others properties to fix this way?
This commit is contained in:
2022-04-01 10:43:08 +02:00
parent 0f73aa3125
commit e72a8a2e9c
7 changed files with 112 additions and 24 deletions

View File

@@ -1,6 +1,9 @@
package compose
import "testing"
import (
"katenary/logger"
"testing"
)
const DOCKER_COMPOSE_YML1 = `
version: "3"
@@ -29,8 +32,20 @@ services:
labels:
katenary.io/ports: "5432"
commander1:
image: foo
command: ["/bin/sh", "-c", "echo 'hello world'"]
commander2:
image: foo
command: echo "hello world"
`
func init() {
logger.NOLOG = true
}
func TestParser(t *testing.T) {
p := NewParser("", DOCKER_COMPOSE_YML1)
p.Parse("test")
@@ -85,5 +100,39 @@ func TestParser(t *testing.T) {
}
}
}
}
func TestParseCommand(t *testing.T) {
p := NewParser("", DOCKER_COMPOSE_YML1)
p.Parse("test")
for name, s := range p.Data.Services {
if name == "commander1" {
t.Log(s.Command)
if len(s.Command) != 3 {
t.Errorf("Expected 3 command, got %d", len(s.Command))
}
if s.Command[0] != "/bin/sh" {
t.Errorf("Expected /bin/sh, got %s", s.Command[0])
}
if s.Command[1] != "-c" {
t.Errorf("Expected -c, got %s", s.Command[1])
}
if s.Command[2] != "echo 'hello world'" {
t.Errorf("Expected echo 'hello world', got %s", s.Command[2])
}
}
if name == "commander2" {
t.Log(s.Command)
if len(s.Command) != 2 {
t.Errorf("Expected 1 command, got %d", len(s.Command))
}
if s.Command[0] != "echo" {
t.Errorf("Expected echo, got %s", s.Command[0])
}
if s.Command[1] != "hello world" {
t.Errorf("Expected hello world, got %s", s.Command[1])
}
}
}
}