-
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.
- Loading branch information
Julien Duchesne
committed
Jul 14, 2019
1 parent
6e69c09
commit e3e5e28
Showing
6 changed files
with
275 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
mockgen: | ||
go get github.com/golang/mock/gomock | ||
go install github.com/golang/mock/mockgen | ||
|
||
rm targets/target_mock_test.go | ||
mockgen -source targets/targets.go -destination targets/target_mock_test.go -package targets |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,72 @@ | ||
package targets | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConfigValidateConfiguration(t *testing.T) { | ||
t.Parallel() | ||
|
||
cases := []struct { | ||
name string | ||
targets []*JenkinsTarget | ||
expected bool | ||
}{ | ||
{ | ||
name: "no targets", | ||
targets: []*JenkinsTarget{}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "valid target", | ||
targets: []*JenkinsTarget{ | ||
&JenkinsTarget{ | ||
Base: Base{Name: "test"}, | ||
URL: "https://test.com", | ||
}, | ||
}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "no name", | ||
targets: []*JenkinsTarget{ | ||
&JenkinsTarget{ | ||
Base: Base{Name: ""}, | ||
URL: "https://test.com", | ||
}, | ||
}, | ||
expected: false, | ||
}, | ||
{ | ||
name: "two actions for unsynced credentials", | ||
targets: []*JenkinsTarget{ | ||
&JenkinsTarget{ | ||
Base: Base{Name: "test", DeleteUnsynced: true, TagUnsynced: true}, | ||
URL: "https://test.com", | ||
}, | ||
}, | ||
expected: false, | ||
}, | ||
{ | ||
name: "bad url (validated by Jenkins)", | ||
targets: []*JenkinsTarget{ | ||
&JenkinsTarget{ | ||
Base: Base{Name: "test"}, | ||
URL: "bad", | ||
}, | ||
}, | ||
expected: false, | ||
}, | ||
} | ||
for _, tt := range cases { | ||
t.Run(tt.name, func(t *testing.T) { | ||
config := &Configuration{JenkinsTargets: tt.targets} | ||
assert.Equal(t, tt.expected, config.ValidateConfiguration()) | ||
for i, gottenItem := range config.AllTargets() { | ||
assert.Equal(t, tt.targets[i], gottenItem) | ||
} | ||
}) | ||
} | ||
} |