Skip to content

Commit

Permalink
feat: add targets for dev and test
Browse files Browse the repository at this point in the history
  • Loading branch information
zeevallin committed Jan 30, 2020
1 parent f9500fa commit 5d134c3
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion targets/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ func (Dev) Restart(ctx context.Context) {
)
}

// Reset returns the development environment to its orginal state
func (Dev) Reset(ctx context.Context) error {
arg := BuildDockerComposeArgs(ProjectName, ProjectType, "test", DockerComposeDevFile)
arg = append(arg, "down")
return Exec(ComposeBin, arg...)
}

// Run runs the service inside docker compose
func (Dev) Run(ctx context.Context) error {
arg := BuildDockerComposeArgs(ProjectName, ProjectType, "dev", DockerComposeDevFile)
Expand All @@ -82,14 +89,30 @@ func Build(ctx context.Context) error {
// Tests is the namespace for actions related to the test environment.
type Tests mg.Namespace

// Start starts the test environment
// Start starts the test environment in docker compose
func (Tests) Start(ctx context.Context) error {
arg := BuildDockerComposeArgs(ProjectName, ProjectType, "test", DockerComposeTestFile)
arg = append(arg, "up", "-d")
arg = append(arg, DockerComposeTestDependencies...)
return Exec(ComposeBin, arg...)
}

// Stop stops the test environment in docker compose
func (Tests) Stop(ctx context.Context) error {
arg := BuildDockerComposeArgs(ProjectName, ProjectType, "test", DockerComposeTestFile)
arg = append(arg, "stop")
arg = append(arg, DockerComposeTestDependencies...)
return Exec(ComposeBin, arg...)
}

// Restart restarts the test environment in docker compose
func (Tests) Restart(ctx context.Context) {
mg.SerialCtxDeps(ctx,
Tests.Stop,
Tests.Start,
)
}

// Reset returns the testing environment to its orginal state
func (Tests) Reset(ctx context.Context) error {
arg := BuildDockerComposeArgs(ProjectName, ProjectType, "test", DockerComposeTestFile)
Expand Down

0 comments on commit 5d134c3

Please sign in to comment.