Skip to content

replace context.Background() with t.Context() #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2025

Conversation

catatsuy
Copy link
Owner

@catatsuy catatsuy commented Mar 2, 2025

This pull request includes updates to the Go module version and improvements to the test context handling in the internal/openai package.

Go module version update:

  • go.mod: Updated the Go version from 1.22.4 to 1.24.0.

Test context handling improvements:

Copy link

github-actions bot commented Mar 2, 2025

Automatic Review

The provided code diff has a few issues that need to be addressed:

Bugs:

  • The use of t.Context() instead of context.Background() in the test functions is incorrect. The method t.Context() is not a standard method for the testing package in Go (unless t is a type that implements such a method, which is not indicated here). The correct approach in the context of Go's testing framework is to use context.Background().

Suggestion:
Replace the calls to t.Context() with context.Background() to avoid any potential runtime errors or unexpected behavior.

Updated lines:

-	res, err := c.Chat(t.Context(), param)
+	res, err := c.Chat(context.Background(), param)

-	_, err = c.Chat(t.Context(), param)
+	_, err = c.Chat(context.Background(), param)

By making this change, you ensure that the tests execute correctly with a proper context, maintaining the intended behavior of the tests.

@catatsuy catatsuy merged commit fd090c4 into main Mar 2, 2025
6 checks passed
@catatsuy catatsuy deleted the refactor-context-usage-in-tests branch March 2, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant