Skip to content

Commit e3405a7

Browse files
authored
Merge pull request #4 from efimovalex/circleci-project-setup
Circleci project setup
2 parents 1122522 + 0269277 commit e3405a7

File tree

3 files changed

+61
-26
lines changed

3 files changed

+61
-26
lines changed

.circleci/config.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Use the latest 2.1 version of CircleCI pipeline process engine.
2+
# See: https://circleci.com/docs/2.0/configuration-reference
3+
version: 2.1
4+
5+
# Define a job to be invoked later in a workflow.
6+
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
7+
jobs:
8+
test:
9+
working_directory: ~/repo
10+
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
11+
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
12+
docker:
13+
- image: circleci/golang:latest
14+
parallelism: 4
15+
# Add steps to the job
16+
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
17+
steps:
18+
- checkout
19+
- restore_cache:
20+
keys:
21+
- go-mod-v4-{{ checksum "go.sum" }}
22+
- run:
23+
name: Install Dependencies
24+
command: go mod download
25+
- save_cache:
26+
key: go-mod-v4-{{ checksum "go.sum" }}
27+
paths:
28+
- "/go/pkg/mod"
29+
- run:
30+
name: Run tests
31+
command: |
32+
mkdir -p /tmp/test-reports
33+
gotestsum --junitfile /tmp/test-reports/unit-tests.xml
34+
- store_test_results:
35+
path: /tmp/test-reports
36+
37+
# Invoke jobs via workflows
38+
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
39+
workflows:
40+
sample: # This is the name of the workflow, feel free to change it to better match your workflow.
41+
# Inside the workflow, you define the jobs you want to run.
42+
jobs:
43+
- test

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

goerr_test.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"log"
99
"net/http"
1010
"os"
11+
"strings"
1112
"testing"
1213

1314
"github.com/stretchr/testify/assert"
@@ -32,16 +33,19 @@ func (t *t1) f3() *Err {
3233

3334
func TestStackTrace(t *testing.T) {
3435
path, _ := os.Getwd()
36+
if os.Getenv("GOPATH") != "" {
37+
path = strings.Replace(path, os.Getenv("GOPATH")+"/src/", "", -1)
38+
}
3539
ts := t1{}
3640
err := ts.f3()
3741

3842
assert.NotNil(t, err)
3943
assert.Equal(t, "message", err.Error())
4044
assert.Equal(t,
4145
fmt.Sprintf(`Error Stacktrace:
42-
-> %[1]s/goerr_test.go:36 (stackerr.TestStackTrace)
43-
-> %[1]s/goerr_test.go:30 (stackerr.(*t1).f3)
44-
-> %[1]s/goerr_test.go:23 (stackerr.f2) context
46+
-> %[1]s/goerr_test.go:40 (stackerr.TestStackTrace)
47+
-> %[1]s/goerr_test.go:31 (stackerr.(*t1).f3)
48+
-> %[1]s/goerr_test.go:24 (stackerr.f2) context
4549
-> %[1]s/goerr_test.go:18 (stackerr.f1)
4650
`, path), err.Sprint())
4751
}
@@ -77,15 +81,19 @@ func TestNewWithStatusCode(t *testing.T) {
7781
}
7882
func TestLog(t *testing.T) {
7983
path, _ := os.Getwd()
84+
if os.Getenv("GOPATH") != "" {
85+
path = strings.Replace(path, os.Getenv("GOPATH")+"/src/", "", -1)
86+
}
87+
8088
var buf bytes.Buffer
8189
log.SetOutput(&buf)
8290
err := f2()
8391
err.Log()
8492
log.SetOutput(os.Stderr)
8593
assert.Contains(t, buf.String(),
8694
fmt.Sprintf(`Error Stacktrace:
87-
-> %[1]s/goerr_test.go:83 (stackerr.TestLog)
88-
-> %[1]s/goerr_test.go:23 (stackerr.f2) context
95+
-> %[1]s/goerr_test.go:91 (stackerr.TestLog)
96+
-> %[1]s/goerr_test.go:24 (stackerr.f2) context
8997
-> %[1]s/goerr_test.go:18 (stackerr.f1)
9098
`, path))
9199
}
@@ -102,6 +110,9 @@ func TestIsNotFound(t *testing.T) {
102110

103111
func TestPrint(t *testing.T) {
104112
path, _ := os.Getwd()
113+
if os.Getenv("GOPATH") != "" {
114+
path = strings.Replace(path, os.Getenv("GOPATH")+"/src/", "", -1)
115+
}
105116
old := os.Stdout // keep backup of the real stdout
106117
r, w, _ := os.Pipe()
107118
os.Stdout = w
@@ -122,8 +133,8 @@ func TestPrint(t *testing.T) {
122133

123134
assert.Equal(t, out,
124135
fmt.Sprintf(`Error Stacktrace:
125-
-> %[1]s/goerr_test.go:117 (stackerr.TestPrint)
126-
-> %[1]s/goerr_test.go:23 (stackerr.f2) context
136+
-> %[1]s/goerr_test.go:128 (stackerr.TestPrint)
137+
-> %[1]s/goerr_test.go:24 (stackerr.f2) context
127138
-> %[1]s/goerr_test.go:18 (stackerr.f1)
128139
`, path))
129140
}

0 commit comments

Comments
 (0)