Skip to content

Commit

Permalink
ci: refactor node controller unit tests
Browse files Browse the repository at this point in the history
Refactor node controller unit tests:
- Break up single test function into multiple test functions
- Create a clear separation between test case input data and expected
  result data
- Implement existing tests with new structure as individual test
  functions
- Avoid checking things that aren't subject matter of the test case at
  hand

related-to: longhorn/longhorn#7332

Signed-off-by: Moritz Röhrich <moritz.rohrich@suse.com>
  • Loading branch information
m-ildefons committed Dec 18, 2023
1 parent 113fe39 commit 4818623
Show file tree
Hide file tree
Showing 2 changed files with 1,097 additions and 571 deletions.
17 changes: 17 additions & 0 deletions controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ func newEngineImage(image string, state longhorn.EngineImageState) *longhorn.Eng
}
}

func newOrphan(spec longhorn.OrphanSpec, status longhorn.OrphanStatus) *longhorn.Orphan {
return &longhorn.Orphan{
ObjectMeta: metav1.ObjectMeta{
Name: types.GetOrphanChecksumNameForOrphanedDirectory(
spec.NodeID,
spec.Parameters[longhorn.OrphanDiskName],
spec.Parameters[longhorn.OrphanDiskPath],
spec.Parameters[longhorn.OrphanDiskUUID],
spec.Parameters[longhorn.OrphanDataName],
),
Namespace: TestNamespace,
},
Spec: spec,
Status: status,
}
}

func newEngineImageDaemonSet() *appsv1.DaemonSet {
return &appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Loading

0 comments on commit 4818623

Please sign in to comment.