Skip to content

Refactor notebook runtime ConfigMap tests: separate empty ConfigMap test case #634

@coderabbitai

Description

@coderabbitai

Summary

This issue tracks the discussion about refactoring the test structure in components/odh-notebook-controller/controllers/notebook_runtime_test.go to improve test organization and clarity.

Background

The current test implementation in PR #623 includes a test loop that handles three scenarios:

  1. ConfigMap with data
  2. ConfigMap without data (empty)
  3. ConfigMap created from ImageStream

Discussion Points

From the PR review discussion:

  • @jstourac initially wanted to remove the ConfigMap altogether but realized the empty ConfigMap test case provides valuable validation that can't be easily simulated with ImageStream due to notebook controller logic
  • @jiridanek suggested that the empty ConfigMap test could be a separate test, not part of the main testData loop

Current Implementation

The test uses a unified structure with test cases that specify either a ConfigMap or imageStream:

testCases := []struct {
    name              string
    notebook          *nbv1.Notebook
    notebookName      string
    ConfigMap         *corev1.ConfigMap
    imageStream       *imagev1.ImageStream
    expectedMountName string
    expectedMountPath string
}{
    // ConfigMap with data case
    // ConfigMap without data case  
    // ImageStream case
}

Possible Implementation Approaches

  1. Separate Test Structure: Extract the empty ConfigMap test case into its own dedicated test function outside the main loop, keeping the loop focused on ConfigMap-with-data and ImageStream scenarios.

  2. Grouped Test Organization: Organize tests into logical groups (e.g., "ConfigMap Tests" and "ImageStream Tests") with separate test loops for better clarity.

  3. Keep Current Structure: Maintain the current unified approach but add clearer documentation/comments about the test case purposes.

Acceptance Criteria

  • Determine the preferred test organization approach
  • Implement the chosen approach
  • Ensure all existing test scenarios remain covered
  • Update test documentation as needed

References

/cc @jstourac @jiridanek

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions