Skip to content

Use constants for mock server addresses and port in unit tests#592

Merged
afritzler merged 1 commit intomainfrom
chore/update-test-variables
Jan 14, 2026
Merged

Use constants for mock server addresses and port in unit tests#592
afritzler merged 1 commit intomainfrom
chore/update-test-variables

Conversation

@xkonni
Copy link
Contributor

@xkonni xkonni commented Jan 14, 2026

in #581 the variables MockServerIP and MockServerPort of a _test.go file were moved into the corresponding suite_test.go file for that package, this PR updates all other tests to do the same.

Summary by CodeRabbit

  • Tests
    • Standardized test configuration by replacing hard-coded server addresses with reusable mock constants across multiple test suites, improving test maintainability and consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

Walkthrough

Introduces three new mock constants (MockServerIP, MockServerIP2, MockServerPort) in the move package and replaces hard-coded IP address and port literals across twelve controller test files and one move test file with these constants for consistency and maintainability.

Changes

Cohort / File(s) Summary
Mock Constants Definition
internal/cmd/move/suite_test.go
Adds three new public constants: MockServerIP ("127.0.0.1"), MockServerIP2 ("127.0.0.2"), and MockServerPort (8000) to the move package.
Move Package Tests
internal/cmd/move/move_test.go
Replaces hard-coded IP literals (127.0.0.1, 127.0.0.2) with MockServerIP and MockServerIP2 constants in EndpointSpec initializations.
Controller Tests (Endpoint/Server Configuration)
internal/controller/endpoint_controller_test.go, internal/controller/server_controller_test.go, internal/controller/serverclaim_controller_test.go, internal/controller/servermaintenance_controller_test.go
Replaces hard-coded values (127.0.0.1 → MockServerIP, 8000 → MockServerPort) in BMCAccess and Endpoint specifications across multiple test scenarios.
Controller Tests (Dynamic Address Construction)
internal/controller/biossettingsset_controller_test.go, internal/controller/biosversionset_controller_test.go, internal/controller/bmcversionset_controller_test.go
Replaces hard-coded IP:port string literals with dynamic construction using fmt.Sprintf("%s:%d", MockServerIP, MockServerPort ± offset) in MockServerIPAddrs initialization. Adds fmt import.
Controller Tests (BIOS/BMC Configuration)
internal/controller/biosversion_controller_test.go, internal/controller/bmc_controller_test.go, internal/controller/bmcsettings_controller_test.go, internal/controller/bmcversion_controller_test.go
Replaces hard-coded IP and port values (127.0.0.1 → MockServerIP, 8000 → MockServerPort) in InlineEndpoint IP fields, Status.IP assertions, and Protocol.Port configurations across multiple BMC and BIOS test cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

area/metal-automation, size/XL

Suggested reviewers

  • Nuckal777
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description is concise and explains the context and purpose clearly, referencing PR#581 and stating the objective of updating all other tests.
Title check ✅ Passed The title accurately reflects the main objective: replacing hard-coded IP and port literals with mock server constants across unit tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@afritzler afritzler changed the title update tests with variables introduced in PR#581 Use contants for mock server addresses and port in unit tests Jan 14, 2026
@afritzler afritzler changed the title Use contants for mock server addresses and port in unit tests Use constants for mock server addresses and port in unit tests Jan 14, 2026
@afritzler afritzler merged commit 6e44628 into main Jan 14, 2026
19 checks passed
@afritzler afritzler deleted the chore/update-test-variables branch January 14, 2026 13:32
@github-project-automation github-project-automation bot moved this to Done in Roadmap Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants