sticky-chef-23784
07/17/2021, 2:08 AMkratos
. To run the test inside the IDE make sure you have the tag -tags sqlite
in the Go tool arguments:
. In the example screenshot I'm looking at login_test.go
and add it to the Run/Debug Configurations
steep-lamp-91158
if you're using Goland you can set the tag globally and just hit the checkbox on a new build configuration under custom tags
steep-lamp-91158
did you know that jetbrains IDEs have an awesome sql debugger, that can open sqlite files? from now on debugging tests is so much easier in keto, you can set a bool flag to use an sqlite file instead of in-mem and then debug after the test failed 😉 😍
https://github.com/ory/keto/pull/638/files#diff-19d74043bd6f4fd4ffaf6dee2895a42da0a754b6135339343117614974ff6182R84
func GetSqlite(t testing.TB, mode sqliteMode) *DsnT {
dsn := &DsnT{
MigrateUp: true,
MigrateDown: false,
}
switch mode {
case SQLiteMemory:
dsn.Name = "memory"
dsn.Conn = fmt.Sprintf("<sqlite://file:%s?_fk=true&cache=shared&mode=memory|sqlite://file:%s?_fk=true&cache=shared&mode=memory>", t.Name())
case SQLiteFile:
t.Cleanup(func() {
_ = os.Remove("TestDB.sqlite")
})
fallthrough
case SQLiteDebug:
dsn.Name = "sqlite"
dsn.Conn = "<sqlite://file:TestDB.sqlite?_fk=true|sqlite://file:TestDB.sqlite?_fk=true>"
}
return dsn
}
white-greece-76805
07/17/2021, 9:52 PMGo: Test Tags
, click Edit in settings.json
and add the following KV to the settings: "go.testTags": "sqlite",