Exemple #1
0
func TestProjectContainer(t *testing.T) {
	project, err := compose.CreateProject("simple", "./assets/simple.yml")
	if err != nil {
		t.Fatal(err)
	}

	if err := project.Start(); err != nil {
		t.Fatal(err)
	}

	container, err := project.Container("hello")
	if err != nil {
		t.Fatal(err)
	}
	if container.Name != "/simple_hello_1" {
		t.Fatalf("expected name '/simple_hello_1', got %s", container.Name)
	}

	if err := project.Scale("hello", 2); err != nil {
		t.Fatal(err)
	}

	_, err = project.Container("hello")
	if err == nil {
		t.Fatalf("expected an error on getting one container, got nothing")
	}

	if err := project.Stop(); err != nil {
		t.Fatal(err)
	}
}
Exemple #2
0
func TestSimpleProject(t *testing.T) {
	project, err := compose.CreateProject("simple", "./assets/simple.yml")
	if err != nil {
		t.Fatal(err)
	}

	err = project.Start()
	if err != nil {
		t.Fatal(err)
	}

	// FIXME(vdemeester) check that a container is running
	runningContainers, err := findContainersForProject("simple")
	if err != nil {
		t.Fatal(err)
	}
	if len(runningContainers) != 1 {
		t.Fatalf("Expected 1 running container for this project, got %v", runningContainers)
	}

	err = project.Stop()
	if err != nil {
		t.Fatal(err)
	}
}
Exemple #3
0
func TestProjectContainers(t *testing.T) {
	project, err := compose.CreateProject("simple", "./assets/simple.yml")
	if err != nil {
		t.Fatal(err)
	}

	if err := project.Start(); err != nil {
		t.Fatal(err)
	}

	if err := project.Scale("hello", 2); err != nil {
		t.Fatal(err)
	}

	containers, err := project.Containers("hello")
	if err != nil {
		t.Fatal(err)
	}

	if len(containers) != 2 {
		t.Fatalf("expected 2 containers, got %v", containers)
	}

	if err := project.Stop(); err != nil {
		t.Fatal(err)
	}
}
Exemple #4
0
// CreateProject creates a compose project with the given name based on the
// specified compose files
func CreateProject(c *check.C, name string, composeFiles ...string) *Project {
	project, err := compose.CreateProject(name, composeFiles...)
	c.Assert(err, check.IsNil,
		check.Commentf("error while creating compose project %s from %v", name, composeFiles))
	return &Project{
		project: project,
	}
}
Exemple #5
0
// CreateProject creates a compose project with the given name based on the
// specified compose files
func CreateProject(t *testing.T, name string, composeFiles ...string) *Project {
	project, err := compose.CreateProject(name, composeFiles...)
	if err != nil {
		t.Fatalf("error while creating compose project %s from %v: %s", name, composeFiles, err.Error())
	}
	return &Project{
		project: project,
	}
}