Home  >  Article  >  Backend Development  >  Go Buffalo test sqlite error: Connection named test not found

Go Buffalo test sqlite error: Connection named test not found

王林
王林forward
2024-02-13 12:15:07562browse

Go Buffalo 测试出现 sqlite 错误:找不到名为 test 的连接

php editor Xinyi discovered that when using Go Buffalo for testing, you may encounter a sqlite error, prompting that the connection named test cannot be found. This error may affect the normal progress of the test and we need to find a solution. The following will introduce some possible causes of this error and provide solutions to help developers solve the problem smoothly.

Question content

I am getting buffalo test errors on new projects I created using this command.

buffalo new coke --db-type sqlite3
buffalo test

This is an error:

[POP] 2023/02/23 13:43:02 warn - unable to load connection development: could not create new connection: sqlite3 support was not compiled into the binary
[POP] 2023/02/23 13:43:02 warn - unable to load connection test: could not create new connection: sqlite3 support was not compiled into the binary
[POP] 2023/02/23 13:43:02 warn - unable to load connection production: could not create new connection: sqlite3 support was not compiled into the binary
Usage:
  buffalo test [flags]

Flags:
  -h, --help   help for test

ERRO[0000] Error: could not find connection named test  

Did I miss anything before running tests on this project? Someone please tell me. Thank you

Solution

The second line of output,

[pop] 2023/02/23 13:43:02 warn - <...>: sqlite3 support was not compiled into the binary

As you can see here, the root cause is that your buffalo binary was not compiled to support sqlite3. How did you install it? If you use go install, you should use the -tags sqlite option, so the command should be

go install -tags sqlite github.com/gobuffalo/cli/cmd/buffalo@latest

See the documentation for more installation options.

https://gobuffalo.io/documentation/ get_started/installation/#custom-installation-with-sqlite3-support

The above is the detailed content of Go Buffalo test sqlite error: Connection named test not found. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete