Skip to content

test(utils): add table-driven unit test coverage for pure helper functions in utils/utils.go #4491

Description

@SatyamPandey-07

Description

Currently, utils/utils_test.go only contains a single test (TestContainerNameFromDockerRun). Several exported pure utility functions in utils/utils.go (such as JSON parsing helpers, IP conversion, and string sanitization utilities) lack dedicated table-driven unit tests.

Adding unit tests for these helper functions will prevent regressions and increase overall test coverage without touching core runtime or proxy logic.

Affected Files

  • utils/utils.go
  • utils/utils_test.go

Proposed Solution / Acceptance Criteria

  1. Add table-driven unit tests using github.com/stretchr/testify/assert or require in utils/utils_test.go.
  2. Cover edge cases (e.g., empty strings, malformed inputs, valid/invalid inputs) for:
    • JSON string validation helpers (e.g., IsJSONString, ContainsValidJSON)
    • IP conversion / network formatting helpers
    • Time / timestamp parsing functions
  3. Ensure all tests run and pass cleanly via go test ./utils/....

Labels

good first issue, unit-tests, help wanted

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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