Skip to content

fix missing skip test when there is no DB available #1594

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
Jun 11, 2024

Conversation

methane
Copy link
Member

@methane methane commented Jun 5, 2024

Description

Fix go test fails when no DB is set up.
Needs backport to 1.8

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary
  • Added myself / the copyright holder to the AUTHORS file

Summary by CodeRabbit

  • Tests
    • Added a conditional check to skip tests if a MySQL server is not available, with a corresponding message.

Copy link

coderabbitai bot commented Jun 5, 2024

Walkthrough

The recent changes introduce a conditional check in the driver_test.go file to skip tests if a MySQL server is not available. This ensures that tests dependent on MySQL do not fail due to the server's unavailability, improving the robustness and reliability of the testing process.

Changes

Files Change Summary
driver_test.go Added a conditional check to skip tests if a MySQL server is not available, with an appropriate message.

Poem

In the code where tests reside,
A check for MySQL now presides.
If the server's out of sight,
Tests won't run, but that's all right.
With this change, our code will gleam,
Robust and strong, like a dream. 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coveralls
Copy link

Coverage Status

coverage: 82.494%. remained the same
when pulling 9e5ce55 on methane:fix-test-without-db
into 2f7015e on go-sql-driver:master.

@methane methane requested a review from shogo82148 June 5, 2024 07:42
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (16)
driver_test.go (16)

Line range hint 2380-2382: Undefined references to internal types and variables.

Please ensure that all referenced types such as mysqlConn, mysqlStmt, binaryRows, and textRows are defined and imported correctly in your project.

Also applies to: 2389-2390, 2397-2400


Line range hint 3311-3311: Undefined reference to MySQLDriver.

Ensure that the MySQLDriver type is correctly defined and accessible within the scope of this file.

Also applies to: 1507-1507


Line range hint 3342-3342: Undefined reference to Config.

Ensure that the Config type from the MySQL driver package is correctly imported and accessible in this file.


Line range hint 43-43: Undefined reference to driverName.

Ensure that driverName is defined and correctly set to the MySQL driver's name in your project.


Line range hint 126-126: Undefined function ParseDSN.

Ensure that the ParseDSN function is defined and correctly imported from the MySQL driver package.

Also applies to: 160-160, 222-222


Line range hint 270-270: Undefined type MySQLError.

Ensure that the MySQLError type is defined and correctly imported from the MySQL driver package to handle MySQL-specific errors.

Also applies to: 2996-2996, 3005-3005


Line range hint 1361-1361: Undefined functions RegisterLocalFile and RegisterReaderHandler.

Ensure that these functions are defined and correctly imported from the MySQL driver package to handle file-based operations.

Also applies to: 1392-1392


Line range hint 1462-1462: Undefined error ErrNoTLS.

Ensure that the ErrNoTLS error is defined and correctly imported from the MySQL driver package to handle TLS-related errors.


Line range hint 1495-1495: Undefined function RegisterTLSConfig.

Ensure that the RegisterTLSConfig function is defined and correctly imported from the MySQL driver package to handle TLS configurations.


Line range hint 1649-1649: Undefined variable defaultBufSize.

Ensure that defaultBufSize is defined and correctly set to manage buffer sizes in your project.


Line range hint 1918-1918: Undefined function readBool.

Ensure that the readBool function is defined and correctly imported to handle boolean reading operations.


Line range hint 1994-1994: Undefined functions related to connection handling.

Ensure that functions like RegisterDialContext, BeforeConnect, and NewConnector are defined and correctly imported from the MySQL driver package to handle connection setups.

Also applies to: 2032-2032, 2059-2059, 2064-2064


Line range hint 2144-2144: Undefined variables and functions related to logging.

Ensure that variables like defaultLogger and functions like SetLogger are defined and correctly imported from the MySQL driver package to handle logging operations.

Also applies to: 2149-2149, 2152-2152


Line range hint 2238-2238: Undefined types mysqlRows and mysqlField.

Ensure that types like mysqlRows and mysqlField are defined and correctly imported from the MySQL driver package to handle row and field operations.

Also applies to: 2240-2240


Line range hint 2591-2591: Undefined type Result.

Ensure that the Result type is defined and correctly imported from the MySQL driver package to handle SQL operation results.


Line range hint 3064-3078: Undefined variables related to scan types.

Ensure that variables like scanTypeBytes, scanTypeNullInt, scanTypeInt8, etc., are defined and correctly set to manage data scanning operations in your project.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2f7015e and 9e5ce55.

Files selected for processing (1)
  • driver_test.go (1 hunks)
Additional context used
golangci-lint
driver_test.go

49-49: undefined: binaryRows (typecheck)


50-50: undefined: textRows (typecheck)


2380-2380: undefined: mysqlConn (typecheck)


2381-2381: undefined: mysqlConn (typecheck)


2382-2382: undefined: mysqlConn (typecheck)


2389-2389: undefined: mysqlStmt (typecheck)


2390-2390: undefined: mysqlStmt (typecheck)


2397-2397: undefined: binaryRows (typecheck)


2398-2398: undefined: textRows (typecheck)


2399-2399: undefined: binaryRows (typecheck)


2400-2400: undefined: textRows (typecheck)


3311-3311: undefined: MySQLDriver (typecheck)


3342-3342: undefined: Config (typecheck)


43-43: undefined: driverName (typecheck)


126-126: undefined: ParseDSN (typecheck)


160-160: undefined: ParseDSN (typecheck)


222-222: undefined: ParseDSN (typecheck)


270-270: undefined: MySQLError (typecheck)


1361-1361: undefined: RegisterLocalFile (typecheck)


1392-1392: undefined: RegisterReaderHandler (typecheck)


1462-1462: undefined: ErrNoTLS (typecheck)


1495-1495: undefined: RegisterTLSConfig (typecheck)


1507-1507: undefined: MySQLDriver (typecheck)


1649-1649: undefined: defaultBufSize (typecheck)


1918-1918: undefined: readBool (typecheck)


1994-1994: undefined: RegisterDialContext (typecheck)


2032-2032: undefined: RegisterDialContext (typecheck)


2059-2059: undefined: BeforeConnect (typecheck)


2064-2064: undefined: NewConnector (typecheck)


2144-2144: undefined: defaultLogger (typecheck)


2149-2149: undefined: SetLogger (typecheck)


2152-2152: undefined: SetLogger (typecheck)


2238-2238: undefined: mysqlRows (typecheck)


2239-2239: undefined: resultSet (typecheck)


2240-2240: undefined: mysqlField (typecheck)


2591-2591: undefined: Result (typecheck)


2996-2996: undefined: MySQLError (typecheck)


3005-3005: undefined: MySQLError (typecheck)


3064-3064: undefined: scanTypeBytes (typecheck)


3065-3065: undefined: scanTypeNullInt (typecheck)


3066-3066: undefined: scanTypeInt8 (typecheck)


3067-3067: undefined: scanTypeNullInt (typecheck)


3068-3068: undefined: scanTypeInt16 (typecheck)


3069-3069: undefined: scanTypeNullInt (typecheck)


3071-3071: undefined: scanTypeInt32 (typecheck)


3073-3073: undefined: scanTypeInt64 (typecheck)


3075-3075: undefined: scanTypeUint8 (typecheck)


3076-3076: undefined: scanTypeUint16 (typecheck)


3077-3077: undefined: scanTypeUint64 (typecheck)


3078-3078: undefined: scanTypeUint32 (typecheck)

@@ -3539,6 +3539,9 @@ func TestConnectionAttributes(t *testing.T) {
}

func TestErrorInMultiResult(t *testing.T) {
if !available {
Copy link

Choose a reason for hiding this comment

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

Ensure proper handling of unavailable MySQL server.

- if !available {
+ if !isMySQLServerAvailable() {

Committable suggestion was skipped due to low confidence.

Copy link
Contributor

@shogo82148 shogo82148 left a comment

Choose a reason for hiding this comment

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

LGTM

@methane methane merged commit 9b8d28e into go-sql-driver:master Jun 11, 2024
32 checks passed
@methane methane deleted the fix-test-without-db branch June 11, 2024 13:49
methane added a commit to methane/mysql that referenced this pull request Jun 11, 2024
Fix `go test` fails when no DB is set up.

(cherry picked from commit 9b8d28e)
@coderabbitai coderabbitai bot mentioned this pull request Jan 23, 2025
5 tasks
@coderabbitai coderabbitai bot mentioned this pull request Apr 20, 2025
5 tasks
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.

3 participants