Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.

Commit 84fff23

Browse files
committed
corrections for tests
1 parent 9f2acec commit 84fff23

File tree

9 files changed

+15
-28
lines changed

9 files changed

+15
-28
lines changed

.circleci/config.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
environment: # environment variables for the build itself
1212
- IN_CONTAINER: true
1313
- DEP_VERSION: 0.5.0
14-
- GOCACHE: "/tmp/go/cache"
14+
- GOCACHE: /tmp/go/cache
1515
- TEST_RESULTS: /tmp/test-results # path to where test results will be saved
1616

1717
steps:
@@ -35,8 +35,7 @@ jobs:
3535
ln -s ${CIRCLE_WORKING_DIRECTORY}/test/configuration/defaults/* /cfgs/defaults/
3636
ln -s ${CIRCLE_WORKING_DIRECTORY}/test/configuration/test/* /cfgs/test/
3737
make race
38-
trap "go-junit-report <${TEST_RESULTS}/go-test.out > ${TEST_RESULTS}/go-test-report.xml" EXIT
39-
make tests | tee ${TEST_RESULTS}/go-test.out
38+
make coverage_cli | tee ${TEST_RESULTS}/go-test.out | go-junit-report > ${TEST_RESULTS}/go-test-report.xml
4039
4140
- store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
4241
path: /tmp/test-results

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
coverage.out
22
.idea
3-
vendor
3+
vendor
4+
go-test*

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ RUN apk update \
2020
&& rm -rf /var/cache/apk/* \
2121
&& rm -rf /tmp/*
2222

23-
COPY . /go/src/gitlab.teamc.io/teamc.io/microservice/configuration/golang-pkg.git
24-
WORKDIR /go/src/gitlab.teamc.io/teamc.io/microservice/configuration/golang-pkg.git
23+
ARG SRC="/go/src/github.com/microparts/configuration-golang"
24+
25+
COPY . ${SRC}
26+
WORKDIR ${SRC}
2527

2628
RUN mkdir -p /cfgs/defaults \
27-
&& mkdir -p /cfgs/test \
28-
&& ln -s /go/src/gitlab.teamc.io/teamc.io/microservice/configuration/golang-pkg.git/test/configuration/defaults/* /cfgs/defaults/ \
29-
&& ln -s /go/src/gitlab.teamc.io/teamc.io/microservice/configuration/golang-pkg.git/test/configuration/test/* /cfgs/test/
29+
&& mkdir -p /cfgs/development \
30+
&& ln -s ${SRC}/test/configuration/defaults/* /cfgs/defaults/ \
31+
&& ln -s ${SRC}/test/configuration/development/* /cfgs/development/
3032

3133
RUN make deps

reader_test.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@ package config
33
import (
44
"github.com/stretchr/testify/assert"
55
"gopkg.in/yaml.v2"
6-
"os"
76
"testing"
87
)
98

109
func TestReadConfigs(t *testing.T) {
1110
t.Run("Success parsing common dirs and files", func(t *testing.T) {
12-
t.Parallel()
13-
err := os.Setenv("STAGE", "test")
1411
configBytes, err := ReadConfigs("./test/configuration")
1512
if !assert.NoError(t, err) {
1613
t.FailNow()
1714
}
18-
err = os.Unsetenv("STAGE")
1915

2016
type cfg struct {
2117
Debug bool `yaml:"debug"`
@@ -46,13 +42,10 @@ func TestReadConfigs(t *testing.T) {
4642
assert.EqualValues(t, refConfig, config)
4743
})
4844
t.Run("Success parsing complex dirs and files", func(t *testing.T) {
49-
t.Parallel()
50-
err := os.Setenv("STAGE", "test")
5145
configBytes, err := ReadConfigs("./test/configuration2")
5246
if !assert.NoError(t, err) {
5347
t.FailNow()
5448
}
55-
err = os.Unsetenv("STAGE")
5649

5750
type hbParams struct {
5851
AreaMapping map[string]string `yaml:"area_mapping"`
@@ -108,19 +101,14 @@ func TestReadConfigs(t *testing.T) {
108101
}{Username: "R_USER", Password: "R_PASS"}}},
109102
}
110103

111-
//log.Fatalf("DefaultList: %+v", config.DefaultList)
112-
113104
assert.EqualValues(t, refConfig, config)
114105
})
115106

116107
t.Run("Success parsing symlinked files and dirs", func(t *testing.T) {
117-
t.Parallel()
118-
err := os.Setenv("STAGE", "test")
119108
configBytes, err := ReadConfigs("./test/symnlinkedConfigs")
120109
if !assert.NoError(t, err) {
121110
t.FailNow()
122111
}
123-
err = os.Unsetenv("STAGE")
124112

125113
type cfg struct {
126114
Debug bool `yaml:"debug"`
@@ -153,13 +141,10 @@ func TestReadConfigs(t *testing.T) {
153141

154142
if GetEnv("IN_CONTAINER", "") == "true" {
155143
t.Run("Success parsing symlinked files and dirs in root", func(t *testing.T) {
156-
t.Parallel()
157-
err := os.Setenv("STAGE", "test")
158144
configBytes, err := ReadConfigs("/cfgs")
159145
if !assert.NoError(t, err) {
160146
t.FailNow()
161147
}
162-
err = os.Unsetenv("STAGE")
163148

164149
type cfg struct {
165150
Debug bool `yaml:"debug"`
@@ -192,7 +177,7 @@ func TestReadConfigs(t *testing.T) {
192177
}
193178

194179
t.Run("Fail dir not found", func(t *testing.T) {
195-
t.Parallel()
180+
196181
_, err := ReadConfigs("")
197182
if !assert.Error(t, err) {
198183
t.FailNow()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
test:
1+
development:
22
debug: true

test/configuration2/test/settings.yaml renamed to test/configuration2/development/settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
test:
1+
development:
22
hotelbook_params:
33
url: https://hotelbook.com/xml_endpoint
44
username: TESt_USERNAME
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../configuration/development/service.yaml

test/symnlinkedConfigs/test/service.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)