Skip to content

Conversation

@ashcrow
Copy link
Member

@ashcrow ashcrow commented Oct 18, 2018

No description provided.

Signed-off-by: Steve Milner <smilner@redhat.com>
@ashcrow
Copy link
Member Author

ashcrow commented Oct 18, 2018

/cc @kikisdeliveryservice

@ashcrow ashcrow mentioned this pull request Oct 18, 2018
4 tasks
@kikisdeliveryservice
Copy link
Contributor

Yay!

@ashcrow Q: line 424 also uses ioutils.ReadAll. Do we need to add that too or will we not need to mock it bc we will/ intend to have dummy resp.Body input that we can test with?

@ashcrow
Copy link
Member Author

ashcrow commented Oct 18, 2018

@kikisdeliveryservice both methods will be updated once this merges :-). The only one I think we can't change at the present is checkFileContentsAndMode (which is OK for now).

@kikisdeliveryservice
Copy link
Contributor

@ashcrow sounds good!
/lgtm

@ashcrow
Copy link
Member Author

ashcrow commented Oct 19, 2018

/retest


// ReadFile provides a mocked implemention
func (f FsClientMock) ReadFile(filename string) ([]byte, error) {
returnValues := f.ReadFileReturns[0]
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be under the if statement to make sure the array is not empty first? E.g.

	if len(f....) > 0 {
		returnValues := f....[0]
		f.... = f.ReadFileReturns[1:]
		return returnValues
	}
	panic("no more values!")

?

I guess, as it is it'll panic anyway with index out of range, which I suppose was the intent since the unit test knows exactly how many times it should be called? But then it seems unnecessary to do the len check since if we got to there it means there definitely is at least one element. So an alternative is to just simplify it to:

	returnValues := f....[0]
	f.... = f.ReadFileReturns[1:]
	return returnValues

? (Though I still prefer the explicitness of the first alternative!)

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea behind this is that:

  • If you provide nothing it panics
  • If you provide N returns and use N+X then X+1 will return the same last element (for example if I want everything to return no error I can just give it one nil, not 2, 5, 50, etc..)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm happy to do a follow on PR to make the panic explicit :-).

Signed-off-by: Steve Milner <smilner@redhat.com>
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 19, 2018
@jlebon
Copy link
Member

jlebon commented Oct 19, 2018

OK, with that last commit, that looks sane to me. 👍
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 19, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ashcrow, jlebon, kikisdeliveryservice

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 71be516 into openshift:master Oct 19, 2018
osherdp pushed a commit to osherdp/machine-config-operator that referenced this pull request Apr 13, 2021
…tion

Add node-selector annotation to namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants