Skip to content
This repository has been archived by the owner on Dec 18, 2020. It is now read-only.

Add unit tests #37

Open
abrarshivani opened this issue Apr 7, 2017 · 3 comments
Open

Add unit tests #37

abrarshivani opened this issue Apr 7, 2017 · 3 comments
Assignees
Labels

Comments

@abrarshivani
Copy link

Add unit tests so that issues can be captured in make ci

@prashima prashima added the task label Apr 7, 2017
@luomiao
Copy link

luomiao commented Apr 28, 2017

Unit tests should be added for new vSphere functionalities/tasks/code.
Usually the unit tests simply reside together with the code need to be tested.
For example,
https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/awsup/aws_utils.go
has its corresponding tests at:
https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/awsup/aws_utils_test.go

Similarly, vSphere's utility code at:
https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/vsphere/vsphere_utils.go
may have its tests vsphere_utils_test.go at the same folder.

Guideline for unit tests:
(I am just borrowing from kubernetes' unit tests guide)

  • Unit tests should be fully hermetic
    • Only access resources in the test binary.
  • All packages and any significant files require unit tests.
  • The preferred method of testing multiple scenarios or input is table driven testing
  • Unit tests must pass on OS X and Windows platforms.
    • Tests using linux-specific features must be skipped or compiled out.
    • Skipped is better, compiled out is required when it won't compile.
  • Concurrent unit test runs must pass.
  • See coding conventions.

We may not need unit tests for every file at once. But we should have the unit tests for significant files first.
Current vSphere packages and files:
pkg/model/vspheremodel/
pkg/resources/delete_cluster_vsphere.go
protokube/pkg/protokube/vsphere_volume.go
upup/pkg/fi/cloudup/vsphere/
upup/pkg/fi/cloudup/vspheretasks/

@pdhamdhere
Copy link

@casualjim We need to put framework in place to easily add and run these unit tests.

@fabulous-gopher
Copy link

This issue was moved to kubernetes#2745

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants