Skip to content

Commit 80c0282

Browse files
authored
feat(project): Add GitHub Actions testing workflow (#289)
GitHub actions is a workflow engine. This testing workflow will - keep everything inside GitHub (one platform) - reduce dependency to an external service (TravisCI) - introduce stricter testing (next to unit tests, staticcheck, fmt, vet) * fix(tests): TestIssueService_GetEditMeta_Fail fails on windows due to error message checking We check the error string in TestIssueService_GetEditMeta_Fail. On different operting systems, this error message is different. See - Linux: TestIssueService_GetEditMeta_Fail: metaissue_test.go:456: Error Get "http://127.0.0.1:65328/rest/api/2/issue/PROJ-9001/editmeta": dial tcp 127.0.0.1:65328: connect: connection refused - Windows: Error Get "http://127.0.0.1:50122/rest/api/2/issue/PROJ-9001/editmeta": dial tcp 127.0.0.1:50122: connectex: No connection could be made because the target machine actively refused it. Now we check the error type instead of the error message * chore(tests): Support only the current + the last two versions go-jira follows Go's Release Policy for testing. See https://golang.org/doc/devel/release.html#policy Related #290
1 parent e1f4265 commit 80c0282

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

.github/workflows/testing.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: Test and lint
12+
strategy:
13+
matrix:
14+
go-version: [1.x, 1.13.x, 1.12.x]
15+
platform: [ubuntu-latest, windows-latest]
16+
runs-on: ${{ matrix.platform }}
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.14
23+
24+
# Caching go modules to speed up the run
25+
- uses: actions/cache@v1
26+
with:
27+
path: ~/go/pkg/mod
28+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
29+
restore-keys: |
30+
${{ runner.os }}-go-
31+
32+
- name: Run go fmt
33+
if: runner.os != 'Windows'
34+
run: diff -u <(echo -n) <(gofmt -d -s .)
35+
36+
- name: Run go vet
37+
run: make vet
38+
39+
- name: Run staticcheck
40+
run: make staticcheck
41+
42+
- name: Run Unit tests.
43+
run: make test

metaissue_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package jira
33
import (
44
"fmt"
55
"net/http"
6-
"strings"
6+
"net/url"
77
"testing"
88
)
99

@@ -451,9 +451,8 @@ func TestIssueService_GetEditMeta_Fail(t *testing.T) {
451451
t.Error("Expected to receive an error, received nil instead")
452452
}
453453

454-
expectedError := "connection refused"
455-
if !strings.Contains(err.Error(), expectedError) {
456-
t.Errorf("Expected to receive error containing %s, received %v instead", expectedError, err.Error())
454+
if _, ok := err.(*url.Error); !ok {
455+
t.Errorf("Expected to receive an *url.Error, got %T instead", err)
457456
}
458457
}
459458

0 commit comments

Comments
 (0)