srl-labs / srl-controller

k8s controller for SR Linux nodes scheduled by KNE
BSD 3-Clause "New" or "Revised" License
16 stars 3 forks source link

Unit tests with fake client #34

Closed hellt closed 1 year ago

hellt commented 1 year ago

This is a first stab at refactoring test harness. It introduces unit tests that use controller-client fake client instead of doing integration tests with envtest right away.

The envtest-based test suite (that uses ginkgo) is moved to ./tests/integration dir and is invoked right now automatically when make test is called.

Running only unit tests is possible with make unit-test.

In future PRs I will carve out ginkgo from the integration test and use go test instead, based on the Cluster API examples - https://github.com/kubernetes-sigs/cluster-api/blob/main/internal/controllers/machinedeployment/suite_test.go

codecov[bot] commented 1 year ago

Codecov Report

Merging #34 (75d6cda) into main (dd417e9) will increase coverage by 0.72%. The diff coverage is n/a.

@@            Coverage Diff             @@
##             main      #34      +/-   ##
==========================================
+ Coverage   65.69%   66.42%   +0.72%     
==========================================
  Files           7        7              
  Lines         548      548              
==========================================
+ Hits          360      364       +4     
+ Misses        164      158       -6     
- Partials       24       26       +2     

see 1 file with indirect coverage changes