Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor mocks packages #368

Merged
merged 1 commit into from
Oct 6, 2021
Merged

Refactor mocks packages #368

merged 1 commit into from
Oct 6, 2021

Conversation

doodlesbykumbi
Copy link
Contributor

What does this PR do?

Moves Conjur mocks to dedicated directory. Binds mocks to struct instances instead of using global variables

What ticket does this PR close?

Resolves -

Checklists

Change log

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR, and/or there is a follow-on issue to update docs, or
  • This PR does not require updating any documentation

@doodlesbykumbi doodlesbykumbi requested review from a team as code owners October 5, 2021 10:45
Copy link
Contributor

@rpothier rpothier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! just a couple minor comments.

conjurSecrets := make(map[string][]byte)

if !CanExecuteConjurVar {
if !c.CanExecute {
return nil, errors.New("custom error")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this error message is existing, but could we change the error message to something better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My take is that the user of the mock should be able to specify their own errors, instead of specifying boolean values like CanExecute. I didn't want the scope of my changes to keep growing so I left TODOs for that.

Copy link
Contributor

@diverdane diverdane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!!
Thanks for taking care of this!


func NewConjurMockClient() ConjurMockClient {
database := map[string]string{
"conjur_variable1": "conjur_secret1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this uses hardcoded, "canned" database entries. Should we add a TODO to make the database entries configurable for a new mock client object? (e.g. by either adding a map[]string argument to NewConjurMockClient, or create an AddSecret method for the object)?

Copy link
Contributor

@rpothier rpothier Oct 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an AddSecret() in 363

eq := reflect.DeepEqual(variableIDsActual, variableIDsExpected)
So(eq, ShouldEqual, true)

So(variableIDsActual, ShouldResemble, variableIDsExpected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T.I.L. Convey has a ShouldResemble.

@rpothier rpothier mentioned this pull request Oct 5, 2021
6 tasks
Copy link
Contributor

@rpothier rpothier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Moves Conjur mocks to dedicated directory. Binds mocks to struct instances instead of using global variables
@codeclimate
Copy link

codeclimate bot commented Oct 6, 2021

Code Climate has analyzed commit 35a04eb and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 94.2% (0.0% change).

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants