Skip to content

Commit 52ef38b

Browse files
authored
Add Go integration tests (#70)
* Add generic integration tests for golang modules Signed-off-by: Joseph Kim <[email protected]>
1 parent 83199fe commit 52ef38b

File tree

134 files changed

+32595
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+32595
-4
lines changed

.github/workflows/gotest.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Devfile Go integration tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
# every day at 9am EST
10+
- cron: 0 1 * * *
11+
jobs:
12+
13+
build:
14+
name: Run Tests
15+
strategy:
16+
matrix:
17+
os: [ ubuntu-latest, macos-10.15 ]
18+
runs-on: ${{ matrix.os }}
19+
continue-on-error: true
20+
timeout-minutes: 20
21+
22+
steps:
23+
24+
- name: Setup Go environment
25+
uses: actions/[email protected]
26+
with:
27+
go-version: 1.15
28+
id: go
29+
30+
- name: Check out code into the Go module directory
31+
uses: actions/checkout@v2
32+
33+
- name: Check go mod status
34+
run: |
35+
make gomod_tidy
36+
if [[ ! -z $(git status -s) ]]
37+
then
38+
echo "Go mod state is not clean"
39+
git diff "$GITHUB_SHA"
40+
exit 1
41+
fi
42+
43+
- name: Check format
44+
run: |
45+
make gofmt
46+
if [[ ! -z $(git status -s) ]]
47+
then
48+
echo "not well formatted sources are found : $(git status -s)"
49+
exit 1
50+
fi
51+
52+
- name: Run Go Tests
53+
run: make test
54+
55+
# - name: Upload Test Coverage results
56+
# uses: actions/upload-artifact@v2
57+
# with:
58+
# name: lib-test-coverage-html
59+
# path: tests/v2/lib-test-coverage.html

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,5 @@ dmypy.json
141141
# Pyre type checker
142142
.pyre/
143143

144+
# Test temp directory
145+
tests/v2/integrationTest/tmp/

Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FILES := main
2+
3+
default: bin
4+
5+
.PHONY: all
6+
all: gomod_tidy gofmt test
7+
8+
.PHONY: gomod_tidy
9+
gomod_tidy:
10+
go mod tidy
11+
12+
.PHONY: gofmt
13+
gofmt:
14+
go fmt -x ./...
15+
16+
.PHONY: bin
17+
bin:
18+
go build *.go
19+
20+
.PHONY: test
21+
test:
22+
go test -v ./tests/v2/integrationTest
23+
# go test -coverprofile tests/v2/lib-test-coverage.out -v ./...
24+
# go tool cover -html=tests/v2/lib-test-coverage.out -o tests/v2/lib-test-coverage.html
25+
26+
.PHONY: clean
27+
clean:
28+
@rm -rf $(FILES)
29+

go.mod

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module github.com/devfile/library
2+
3+
go 1.15
4+
5+
require (
6+
github.com/devfile/api/v2 v2.0.0-20220309195345-48ebbf1e51cf
7+
github.com/fatih/color v1.7.0
8+
github.com/fsnotify/fsnotify v1.4.9
9+
github.com/gobwas/glob v0.2.3
10+
github.com/golang/mock v1.5.0
11+
github.com/google/go-cmp v0.5.5
12+
github.com/google/go-github v17.0.0+incompatible // indirect
13+
github.com/google/go-querystring v1.1.0 // indirect
14+
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7
15+
github.com/hashicorp/go-multierror v1.1.1
16+
github.com/hashicorp/go-version v1.3.0
17+
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348
18+
github.com/mattn/go-colorable v0.1.2 // indirect
19+
github.com/mattn/go-isatty v0.0.12 // indirect
20+
github.com/onsi/ginkgo v1.16.4
21+
github.com/onsi/gomega v1.14.0
22+
github.com/openshift/api v0.0.0-20200930075302-db52bc4ef99f
23+
github.com/openshift/odo v1.2.6
24+
github.com/pkg/errors v0.9.1
25+
github.com/spf13/afero v1.2.2
26+
github.com/stretchr/testify v1.7.0
27+
github.com/tidwall/gjson v1.14.1
28+
github.com/xeipuuv/gojsonschema v1.2.0
29+
k8s.io/api v0.21.3
30+
k8s.io/apimachinery v0.21.3
31+
k8s.io/client-go v0.21.3
32+
k8s.io/klog v1.0.0
33+
k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471
34+
sigs.k8s.io/controller-runtime v0.9.5
35+
sigs.k8s.io/yaml v1.2.0
36+
)

go.sum

+816
Large diffs are not rendered by default.

local/odo/tests/integration/devfile/cmd_devfile_create_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ var _ = Describe("odo devfile create command tests", func() {
5050
})
5151

5252
Measure("should successfully create the devfile component with valid component name", func(b Benchmarker) {
53-
runtime := b.Time("========== Command: odo create java-openliberty " +
54-
cmpName + " ==========", func() {
53+
runtime := b.Time("========== Command: odo create java-openliberty "+
54+
cmpName+" ==========", func() {
5555
helper.Cmd("odo", "create", "java-openliberty", cmpName).ShouldPass()
5656
})
5757
b.RecordValueWithPrecision("========== Execution time in ms ==========", float64(runtime.Milliseconds()), "ms", 2)

0 commit comments

Comments
 (0)