Skip to content

chore(app): tidying up a few tests#76

Merged
Jacobbrewer1 merged 3 commits intomainfrom
feat/test-cleaning
May 12, 2025
Merged

chore(app): tidying up a few tests#76
Jacobbrewer1 merged 3 commits intomainfrom
feat/test-cleaning

Conversation

@Jacobbrewer1
Copy link
Owner

Describe your changes

This pull request focuses on improving test coverage, enhancing test clarity, and optimizing parallel execution in the codebase. The most significant changes include refining error assertions, restructuring test cases for better readability, enabling parallelism in tests, and optimizing a benchmark function for concurrent execution.

Improvements to test clarity and assertions:

  • app_test.go: Updated the error assertion in TestApp_StartServer to use require.EqualError for a more descriptive error message when a server already exists.
  • health/result_test.go: Renamed TestResult_AddDetail_NilMap to TestResult_AddDetail and added a subtest to handle cases where the Result object is nil, improving test case organization and readability. [1] [2]

Enhancements to parallelism in tests:

  • logging/config_test.go: Added t.Parallel() to TestNewLoggingConfig and its subtests to enable concurrent execution, improving test performance. [1] [2]

Optimization in benchmark execution:

  • logging/logger_test.go: Modified the BenchmarkReplaceAttrs function to use b.RunParallel, allowing concurrent execution of benchmark iterations for better performance testing.

@Jacobbrewer1 Jacobbrewer1 marked this pull request as ready for review May 12, 2025 08:31
Copilot AI review requested due to automatic review settings May 12, 2025 08:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request tidies up tests to improve clarity, increase test coverage, and optimize execution performance. Key changes include:

  • Refining error assertions in TestApp_StartServer.
  • Enabling parallelism in tests via t.Parallel() in logging/config_test.go.
  • Restructuring TestResult_AddDetail in health/result_test.go and optimizing benchmark execution in logging/logger_test.go.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
app_test.go Updated error assertion in TestApp_StartServer to use require.EqualError for precision.
logging/config_test.go Added t.Parallel() calls in TestNewLoggingConfig and its subtests to enable concurrent testing.
logging/logger_test.go Modified BenchmarkReplaceAttrs to utilize b.RunParallel for concurrent benchmark iterations.
health/result_test.go Renamed and refactored TestResult_AddDetail with an additional subtest for nil Result handling.

@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot May 12, 2025 08:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR tidies up various tests to improve clarity and performance. Key changes include refining error assertions in the app tests, restructuring and renaming test cases in the health module, and enabling parallel execution in both benchmark and unit tests to optimize performance.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
logging/logger_test.go Refactored the benchmark to execute iterations in parallel using b.RunParallel.
health/result_test.go Renamed and expanded the test to include a subtest for handling nil Result objects.
app_test.go Updated error assertions to provide more descriptive error messages using EqualError.
Comments suppressed due to low confidence (1)

logging/logger_test.go:155

  • Ensure that bm.attr used in replaceAttrs is safe for concurrent access. If bm.attr is mutable or shared among iterations, consider using a thread-safe or isolated copy to prevent potential race conditions.
b.RunParallel(func(pb *testing.PB) {

@Jacobbrewer1 Jacobbrewer1 merged commit 07ce557 into main May 12, 2025
6 checks passed
@Jacobbrewer1 Jacobbrewer1 deleted the feat/test-cleaning branch May 12, 2025 08:39
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants