buildpacks / libcnb

A non-opinionated language binding for the Cloud Native Buildpack Buildpack and Extension specifications
Apache License 2.0
32 stars 13 forks source link

Provide handy mocks and testing utilities #53

Open samj1912 opened 3 years ago

samj1912 commented 3 years ago

Currently almost every buildpack that uses libcnb and has tests has to write code to create mock contexts etc. We should consider adding this to the existing set of mocks.

~We should also consider adding utilities for integration testing buildpacks (possibly in a separate library) that possibly uses pack and docker. Example of something like this https://github.com/paketo-buildpacks/occam~

dmikusa commented 9 months ago

I'm going to split the second part of this into a separate issue. See #259.

I'd like to see this for v2, and I have some ideas.

In Paketo tests, we frequently need to create some part of the context & layers by making temp directories. It would be nice to have some convenient API to build that for tests. It'll be more of a stub than a mock, but I think it could be beneficial & reduce test code.

We've also used Gomega in testing for libcnb. I think it might be helpful to add some Gomega matchers for common assertions. This could reduce code in tests as well.

That's off the top of my head. I'm going to look through Paketo buildpacks more and see what else jumps out as possibilities for reducing boiler plate code in tests.

@samj1912 Let me know if you had other ideas in mind here too. Thanks

loewenstein commented 1 month ago

@dmikusa is this in the 2.0 milestone because it cannot be done in 1.x or because it is a requirement to release 2.0?

cc @samj1912