-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from marcosnils/container_services
Container services
- Loading branch information
Showing
10 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
prepare: | ||
go get -d -v -t ./... | ||
docker-compose up -d --no-recreate | ||
|
||
test: prepare | ||
go test -short ./... | ||
|
||
update: | ||
go get -u -v -d -t ./... | ||
|
||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
mysql: | ||
image: mysql | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
|
||
memcached: | ||
image: memcached | ||
ports: | ||
- "11211:11211" | ||
|
||
postgres: | ||
image: postgres | ||
ports: | ||
- "5432:5432" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package testutil | ||
|
||
import "os" | ||
|
||
var localhost = "localhost" | ||
|
||
func GetLocalHost() string { | ||
if dockerHostVar := os.Getenv("DOCKER_HOST"); dockerHostVar != "" { | ||
return dockerHostVar | ||
} | ||
return localhost | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package testutil | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestDockerHost(t *testing.T) { | ||
|
||
os.Unsetenv("DOCKER_HOST") | ||
|
||
host := GetLocalHost() | ||
|
||
if host != localhost { | ||
t.Fatalf("Host should be localhost when DOCKER_HOST is not set. Current value [%s]", host) | ||
} | ||
|
||
os.Setenv("DOCKER_HOST", "1.1.1.1") | ||
|
||
host = GetLocalHost() | ||
|
||
if host != "1.1.1.1" { | ||
t.Fatalf("Host should take DOCKER_HOST value when set. Current value is [%s] and DOCKER_HOST is [%s]", host, os.Getenv("DOCKER_HOST")) | ||
} | ||
|
||
} |