-
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 16, 2019
1 parent
e3e5e28
commit 95bd261
Showing
10 changed files
with
302 additions
and
24 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 |
---|---|---|
@@ -1,6 +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 | ||
|
||
mockgen -source targets/targets.go -destination targets/targets_mock.go -package targets -self_package github.com/coveooss/credentials-sync/targets | ||
mockgen -source credentials/sources.go -destination credentials/sources_mock.go -package credentials -self_package github.com/coveooss/credentials-sync/credentials |
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,38 @@ | ||
package sync | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/coveooss/credentials-sync/credentials" | ||
"github.com/coveooss/credentials-sync/targets" | ||
"github.com/golang/mock/gomock" | ||
) | ||
|
||
func setSourceMock(t *testing.T, config *Configuration) *credentials.MockSource { | ||
ctrl := gomock.NewController(t) | ||
source := credentials.NewMockSource(ctrl) | ||
sourceCollection := credentials.NewMockSourceCollection(ctrl) | ||
sourceCollection.EXPECT().AllSources().Return([]credentials.Source{source}).AnyTimes() | ||
|
||
config.SetSources(sourceCollection) | ||
return source | ||
} | ||
|
||
func setTargetMock(t *testing.T, config *Configuration) *targets.MockTarget { | ||
ctrl := gomock.NewController(t) | ||
target := targets.NewMockTarget(ctrl) | ||
targetCollection := targets.NewMockTargetCollection(ctrl) | ||
targetCollection.EXPECT().AllTargets().Return([]targets.Target{target}).AnyTimes() | ||
|
||
config.SetTargets(targetCollection) | ||
return target | ||
} | ||
|
||
func TestDeleteListOfCredentials(t *testing.T) { | ||
config := &Configuration{} | ||
setSourceMock(t, config) | ||
target := setTargetMock(t, config) | ||
target.EXPECT().GetExistingCredentials().Return([]string{"test123"}).AnyTimes() | ||
|
||
target.EXPECT().DeleteCredentials("test123").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
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,16 @@ | ||
package targets | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestJenkinsToString(t *testing.T) { | ||
jenkins := &JenkinsTarget{ | ||
Base: Base{Name: "targetName", Tags: map[string]string{"my_tag": "tag_value"}}, | ||
URL: "test.com", | ||
} | ||
|
||
assert.Equal(t, "targetName [Tags: my_tag=tag_value] (Jenkins) - test.com", jenkins.ToString()) | ||
} |
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.