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

Introduce unit-testing through the Ginkgo BDD framework #68

Merged
merged 12 commits into from
Sep 7, 2022

Conversation

RobotSail
Copy link
Collaborator

@RobotSail RobotSail commented Aug 30, 2022

This PR aims to introduce behavior-driven development (BDD) through the usage of Ginkgo + Gomega.

A test scenario is created with the

var _ = Describe("my component", func() {
  // test flow here
})

blocks.

Simply instantiate the structs, populate them with the data pertinent to your scenario, and create It statements to describe what "it" does.

For example, the IpfsReconciler.ConfigMapScripts method has one of its behaviors described like so:

When("ConfigMapScripts are edited", func() {
  const myName = "my-fav-ipfs-node"
  BeforeEach(func() {
	  // uses the name
	  ipfs.Name = myName
  })
  
  It("contains the IPFS resource name", func() {
	  fn, name := ipfsReconciler.ConfigMapScripts(ctx, ipfs, configMap)
	  Expect(fn).NotTo(BeNil())
	  Expect(fn()).NotTo(HaveOccurred())
	  Expect(name).To(Equal("ipfs-cluster-scripts-" + myName))
  })
})

Fixes #22

@RobotSail RobotSail changed the title Robot sail/issue22 Introduce unit-testing through the Ginkgo BDD framework Sep 1, 2022
@RobotSail RobotSail merged commit 9a99bd0 into ipfs-cluster:main Sep 7, 2022
@RobotSail RobotSail deleted the RobotSail/issue22 branch September 7, 2022 13:30
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.

unit testing
1 participant