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

Testing issues #27

Closed
paulbdavis opened this issue Oct 30, 2019 · 11 comments
Closed

Testing issues #27

paulbdavis opened this issue Oct 30, 2019 · 11 comments

Comments

@paulbdavis
Copy link
Contributor

I am trying to work on #26 and I am having issues running the tests.

I managed to get it working with my minikube setup, but I am getting the following error:

assert: mock: I don't know what to return because the method call was unexpected.
	Either do Mock.On("GetOAuth2Client").Return(...) first, or remove the GetOAuth2Client() call.
	This method was unexpected:
		GetOAuth2Client(string)
		0: "testClientID"
	at: [HydraClientInterface.go:29 oauth2client_controller.go:95 suite_test.go:98 reconcile.go:93 controller.go:216 controller.go:192 controller.go:171 wait.go:152 wait.go:153 wait.go:88 asm_amd64.s:1357]

I tried to run mockery -name=HydraClientInterface in controllers/mocks but it returns the error Unable to find HydraClientInterface in any go files under this path

@aeneasr
Copy link
Member

aeneasr commented Oct 31, 2019

@paulbdavis
Copy link
Contributor Author

I did follow that, the initial make test is what is failing.

Using the feature/minikube-test branch of my repo (in #28), I can get the first test (api/oauth_2_client_types_test.go) to run sucessfully with the patches I've added, but I still get the error described in the OP when the second test runs (controller/suite_test.go)

To test my changes, I just started a basic minikube cluster on my machine (minikube start --vm-driver kvm2) and tried to run the test against that (my fork currently defaults USE_EXISTING_CLUSTER to t [any non empty value triggers the local cluster] though that bit will be reverted once it's ready)

From the error, it looks like I'm just missing some mock files that need to be generated, but aside from the mockery -name={INTERFACE_NAME} in the README (which didn't work, as described in OP) there is no mention of generating any files for the tests to run.

@aeneasr
Copy link
Member

aeneasr commented Nov 2, 2019

@jakkab could you maybe help clarify this?

@jakkab
Copy link
Contributor

jakkab commented Nov 5, 2019

@paulbdavis @aeneasr I'm on it.

@jakkab
Copy link
Contributor

jakkab commented Nov 5, 2019

@paulbdavis The file containing the target interface (oauth2client_controller.go) is not under controllers/mocks. Try running mockery -name=HydraClientInterface in the controllers dir. Anyways, generating new mocks won't do the trick, I'm afraid. Let me dig into it.

@jakkab
Copy link
Contributor

jakkab commented Nov 5, 2019

@paulbdavis What's the reason behind switching those tests to minikube?

@paulbdavis
Copy link
Contributor Author

paulbdavis commented Nov 5, 2019

@jakkab It's not just a switch to minikube, but allowing testing on any existing cluster (I just set up minikube for simplicity, since the CRD is in use on my existing clusters). It's enabled by a variable in the makefile though, so the existing test would still be the default (it's enabled by default in my current PR branch, but that would be changed before it's done)

@paulbdavis
Copy link
Contributor Author

@paulbdavis The file containing the target interface (oauth2client_controller.go) is not under controllers/mocks. Try running mockery -name=HydraClientInterface in the controllers dir. Anyways, generating new mocks won't do the trick, I'm afraid. Let me dig into it.

I assumed that it was already generated, but I tried again anyway, the only thing that changed in the generated file was the format of the import statement.

Either way, I am getting that same error with the newly generated file as well.

@paulbdavis
Copy link
Contributor Author

I finally figured out that I just needed to install kubebuilder to get the default testing to work. I'll just make a PR stating such in the README for simplicity

@jakkab
Copy link
Contributor

jakkab commented Nov 6, 2019

I assumed that it was already generated, but I tried again anyway, the only thing that changed in the generated file was the format of the import statement.

Either way, I am getting that same error with the newly generated file as well.

This is correct, no interface has been added meaning no new mocks are required.

@jakkab
Copy link
Contributor

jakkab commented Nov 6, 2019

@paulbdavis

I finally figured out that I just needed to install kubebuilder to get the default testing to work. I'll just make a PR stating such in the README for simplicity

Thank you!

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

No branches or pull requests

3 participants