Skip to content

Commit d3f4ea5

Browse files
committed
Add travis-ci and update tests
This adds travis-ci support and updates a few tests and makefile stuffs in order to make it pass under travis
1 parent 93edc41 commit d3f4ea5

6 files changed

Lines changed: 64 additions & 23 deletions

File tree

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: go
2+
sudo: false
3+
os:
4+
- linux
5+
- osx
6+
go:
7+
- 1.4
8+
- 1.5
9+
before_install: ./scripts/hack/symlink-gopath-travisci
10+
script:
11+
- make test
12+
- make
13+
- ./bin/local/ecs-cli --version

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
ROOT := $(shell pwd)
1515

16-
all: generate build
16+
all: build
1717

1818
SOURCEDIR=./ecs-cli
1919
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
@@ -29,12 +29,18 @@ $(LOCAL_BINARY): $(SOURCES)
2929
@echo "Built ecs-cli"
3030

3131
.PHONY: test
32-
test: generate
33-
. ./scripts/shared_env && go test -timeout=120s -v -cover github.com/aws/amazon-ecs-cli/ecs-cli/modules/...
32+
test:
33+
. ./scripts/shared_env && go test -timeout=120s -v -cover ./ecs-cli/modules/...
3434

3535
.PHONY: generate
3636
generate: $(SOURCES)
37-
. ./scripts/shared_env && go install github.com/golang/mock/mockgen && go generate github.com/aws/amazon-ecs-cli/ecs-cli/modules/...
37+
. ./scripts/shared_env && go generate ./ecs-cli/modules/...
38+
39+
.PHONY: generate-deps
40+
generate-deps:
41+
go install github.com/golang/mock/mockgen
42+
go get golang.org/x/tools/cmd/goimports
43+
3844

3945
.PHONY: docker-build
4046
docker-build:

ecs-cli/modules/command/cluster_app_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,21 @@ func TestClusterUp(t *testing.T) {
5252
mockEcs := mock_ecs.NewMockECSClient(ctrl)
5353
mockCloudformation := mock_cloudformation.NewMockCloudformationClient(ctrl)
5454

55-
mockEcs.EXPECT().Initialize(gomock.Any())
56-
mockEcs.EXPECT().CreateCluster(gomock.Any()).Do(func(in interface{}) {
57-
if in.(string) != clusterName {
58-
t.Fatal("Expected to be called with " + clusterName + " not " + in.(string))
59-
}
60-
}).Return(clusterName, nil)
55+
gomock.InOrder(
56+
mockEcs.EXPECT().Initialize(gomock.Any()),
57+
mockEcs.EXPECT().CreateCluster(gomock.Any()).Do(func(in interface{}) {
58+
if in.(string) != clusterName {
59+
t.Fatal("Expected to be called with " + clusterName + " not " + in.(string))
60+
}
61+
}).Return(clusterName, nil),
62+
)
6163

62-
mockCloudformation.EXPECT().Initialize(gomock.Any())
63-
mockCloudformation.EXPECT().ValidateStackExists(gomock.Any()).Return(errors.New("error"))
64-
mockCloudformation.EXPECT().CreateStack(gomock.Any(), gomock.Any(), gomock.Any()).Return("", nil)
65-
mockCloudformation.EXPECT().WaitUntilCreateComplete(gomock.Any()).Return(nil)
64+
gomock.InOrder(
65+
mockCloudformation.EXPECT().Initialize(gomock.Any()),
66+
mockCloudformation.EXPECT().ValidateStackExists(gomock.Any()).Return(errors.New("error")),
67+
mockCloudformation.EXPECT().CreateStack(gomock.Any(), gomock.Any(), gomock.Any()).Return("", nil),
68+
mockCloudformation.EXPECT().WaitUntilCreateComplete(gomock.Any()).Return(nil),
69+
)
6670

6771
globalSet := flag.NewFlagSet("ecs-cli", 0)
6872
globalSet.String("region", "us-west-1", "")

ecs-cli/modules/config/params_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ func (rdwr *mockReadWriter) Save(dest *Destination) error {
4343
}
4444

4545
func TestNewCliParamsFromEnvVars(t *testing.T) {
46+
os.Clearenv()
47+
4648
globalSet := flag.NewFlagSet("ecs-cli", 0)
4749
globalContext := cli.NewContext(nil, globalSet, nil)
4850
context := cli.NewContext(nil, nil, globalContext)
4951
rdwr := &mockReadWriter{}
50-
os.Unsetenv("AWS_REGION")
51-
os.Unsetenv("AWS_DEFAULT_REGION")
5252
_, err := NewCliParams(context, rdwr)
5353
if err == nil {
5454
t.Errorf("Expected error when region not specified")
5555
}
5656

5757
os.Setenv("AWS_REGION", "us-west-1")
58+
os.Setenv("AWS_ACCESS_KEY", "AKIDEXAMPLE")
59+
os.Setenv("AWS_SECRET_KEY", "SECRET")
5860
params, err := NewCliParams(context, rdwr)
5961
if err != nil {
6062
t.Errorf("Unexpected error when region is specified using environment variable AWS_REGION: ", err)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"). You may
5+
# not use this file except in compliance with the License. A copy of the
6+
# License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0/
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
15+
set -ex
16+
17+
# Because of how gopaths work, you want a canonicalized import path even when
18+
# developing on a fork of the repository.
19+
# This creates a usable symlink at the canonical gopath so that go imports work
20+
if [[ ! -d "$HOME/gopath/src/github.com/aws/amazon-ecs-cli" ]]; then
21+
mkdir -p "$HOME/gopath/src/github.com/aws"
22+
ln -s "$(pwd)" "$HOME/gopath/src/github.com/aws/amazon-ecs-cli"
23+
fi

scripts/shared_env

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
# This script should be sourced by bash or zsh prior to doing basically
1616
# anything
17-
18-
for godepPath in "$(find ecs-cli/vendor -path "*/Godeps/_workspace")"; do
19-
export GOPATH="$(pwd)/${godepPath}:${GOPATH}"
20-
done
21-
2217
vendor="$(pwd)/ecs-cli/vendor"
2318
export GOPATH="${vendor}:${GOPATH}"
24-
echo GOPATH="${GOPATH}"
25-
2619
export PATH="${vendor}/bin:$(pwd)/scripts:${PATH}"

0 commit comments

Comments
 (0)