-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests and SonarCloud integration
- Loading branch information
Showing
15 changed files
with
268 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
language: go | ||
sudo: false | ||
dist: trusty | ||
go: | ||
- 1.13.x | ||
matrix: | ||
fast_finish: true | ||
include: | ||
- env: GOOS="linux" | ||
- env: GOOS="windows" | ||
- env: GOOS="darwin" | ||
- 1.13.x | ||
script: | ||
- make clean binary | ||
- sonar-scanner | ||
branches: | ||
only: | ||
- master | ||
- develop | ||
- /^v\d/ | ||
- master | ||
- develop | ||
- "/^v\\d/" | ||
notifications: | ||
email: onchange | ||
addons: | ||
sonarcloud: | ||
organization: "wavesoftware" | ||
token: | ||
secure: "V+dI4AgutA5XbYXgXnf1pbgG49dZE34Yz5FlM5OjMNKCagMhM3C/t0bYJrM02GUw5oI29c3APgh0TbVLKQTUL/WOSMkRli2IikUaX6gJNI1ClL/AsikaCwvIWEqDUqoKMS27T1Un4ipXbeeEkjrDVbew8C1zBYEJvDQY463GiAy/kwQ/llL40wBttmy1Wflags12sjKBfxVPmmyO8BbOeu/zYca9g48EOD0xcQVGVRvZqoOP3SwXETaU0+7F2pKd3qZbjnbpH+aJL6hI+UIAQB3iv2vWTHscMczilRmPRO7vueBC1SB41X42fG1LqQJ0vkxgMSVKftatGykrmJcrNWubK2bpczRF4sf9RhdugkE3pPR5KnstHl0VVSII4IFsQnkgPTl+2PFdPW8qxdiW4p9YI1S3iYydO3POqBcksbOj+QTbkSAxy5z6DnOoVUMZnEUAIVnyP/hfzSMTr8Q8YgFdZuuZcUMzo04Fr1ZJhboOFCo6ZMx+WcOlRd56u1KVohwhQ/gu7TalbKUMfoLwsRwNaCRiXXAmum94NLHIDK50PQwnA3DJc4JznZIVqY4SllSdWjA0fCLgSGD6rU7p9XC8/7DLyrzc1hEsKgf7UYi5bxwUPZAmH6M33XM0EaKeaZaeCtD5y5ITpg2Q0H1qeJUx/0kbWT69J2H6BYPjLUA=" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package contract | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestStruct(t *testing.T) { | ||
// when | ||
answers := LocationAwareAnswers{} | ||
|
||
// then | ||
assert.NotNil(t, answers) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package logic | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/wavesoftware/serverless-installer/internal/domain/model" | ||
) | ||
|
||
var files []file | ||
|
||
func TestSave(t *testing.T) { | ||
// given | ||
files = nil | ||
service := answersService{ | ||
fileWriter: stubWriter{}, | ||
} | ||
answers := model.Answers{} | ||
answers.Jeager.Install.Enabled = false | ||
path := "/tmp/answers.yaml" | ||
expectedYaml := strings.ReplaceAll(`jeager: | ||
install: | ||
enabled: false | ||
elasticsearch: | ||
install: | ||
enabled: false | ||
kiali: | ||
install: | ||
enabled: false | ||
istio: | ||
install: | ||
enabled: false | ||
serverless: | ||
install: | ||
enabled: false | ||
`, "\t", " ") | ||
|
||
// when | ||
err := service.Save(answers, path) | ||
|
||
// then | ||
assert.Nil(t, err) | ||
assert.Len(t, files, 1) | ||
first := files[0] | ||
assert.Equal(t, path, first.path) | ||
assert.Equal(t, expectedYaml, string(first.contents)) | ||
} | ||
|
||
type file struct { | ||
contents []byte | ||
path string | ||
} | ||
|
||
type stubWriter struct{} | ||
|
||
func (w stubWriter) Write(contents []byte, path string) error { | ||
files = append(files, file{ | ||
contents: contents, | ||
path: path, | ||
}) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package logic | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCreateAnswersSaver(t *testing.T) { | ||
// when | ||
saver := CreateAnswersSaver() | ||
|
||
// then | ||
assert.NotNil(t, saver) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package model | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestStruct(t *testing.T) { | ||
// when | ||
answers := Answers{} | ||
|
||
// then | ||
assert.NotNil(t, answers) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package persistence | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCreateFileWriter(t *testing.T) { | ||
// when | ||
writer := CreateFileWriter() | ||
|
||
// then | ||
assert.NotNil(t, writer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.