Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Dedicated fixtures in tests #1783

Closed
hiddeco opened this issue Mar 1, 2019 · 7 comments
Closed

Dedicated fixtures in tests #1783

hiddeco opened this issue Mar 1, 2019 · 7 comments
Labels
build About the build or test scaffolding

Comments

@hiddeco
Copy link
Member

hiddeco commented Mar 1, 2019

From #1394 (comment)

The fixtures in cluster/kubernetes/testfiles are reused throughout the code base. We should write dedicated fixtures for each package that 'borrows' these so they become self-contained.

@2opremio 2opremio added the build About the build or test scaffolding label Mar 4, 2019
@yiannistri
Copy link
Contributor

@hiddeco @2opremio I'd be willing to get a PR/discussion going on this and get feedback if you like (or agree that the current approach is good enough 😄) So from my understanding the challenges are:

  • Test fixtures are buried in one package that many other packages are using
  • Keep test code close to the package
  • Avoid having (almost) identical test fixtures in many places

Is there anything else I should take into account?

@2opremio
Copy link
Contributor

2opremio commented Feb 3, 2020

I think it would also be good to have varied fixtures and incorporate fixtures employing .flux.yaml files. But maybe that's out of scope.

@yiannistri
Copy link
Contributor

By varied fixtures do you mean the ability to build different test data according to the needs of each test? Like fluent test data builders?

@2opremio
Copy link
Contributor

2opremio commented Feb 5, 2020

Yes.

@yiannistri
Copy link
Contributor

yiannistri commented Feb 9, 2020

I've opened a (WIP) PR to track this. Let me know if I'm going down the right path 🙂

@yiannistri
Copy link
Contributor

I have moved the (non-encrypted) test fixtures to /test as they are shared. It seems to me that they serve two needs:

  • As test fixtures for when initialising a git repo to test git operations
  • As test fixtures for when they are read to ensure they are parsed correctly

Although they don't need to be shared, I can understand the convenience of having a single set of files. Do you think there's value in splitting them?

I would also like some input before continuing with the test data builders as it can be subjective. I would use them for building complicated in-memory objects but in this case the simplicity of having the plain yaml there in each test may be preferred. If so, which tests would benefit more from using test data builders in your opinion?

@hiddeco @2opremio thoughts?

@kingdonb
Copy link
Member

The PR that goes with this report has been closed by the contributor.

I am closing this issue, as it appears to be outside the scope of maintenance mode in Flux v1. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build About the build or test scaffolding
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants