Skip to content
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

TestCollectionDAOFindOrCreate fails #375

Closed
2 tasks done
tjex opened this issue Jan 5, 2024 · 3 comments
Closed
2 tasks done

TestCollectionDAOFindOrCreate fails #375

tjex opened this issue Jan 5, 2024 · 3 comments
Assignees

Comments

@tjex
Copy link
Member

tjex commented Jan 5, 2024

Check if applicable

  • I have searched the existing issues (required)
  • I'm willing to help fix the problem and contribute a pull request

Describe the bug

Testing the package, returns a failed test for TestCollectionDAOFindOrCreate in ./internal/adapter/sqlite/collection_dao_test.go.

But running the test manually, as well as all others in the test stack trace pass.

--- FAIL: TestCollectionDAOFindOrCreate (0.00s)
    assert.go:27: Expected `failed to migrate the database: database migration failed: no such module: fts5` (type *fmt.wrapError) to be nil
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x100ccade8]

goroutine 19 [running]:
testing.tRunner.func1.2({0x100e78ce0, 0x10106c5a0})
	/opt/homebrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1545 +0x1c4
testing.tRunner.func1()
	/opt/homebrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1548 +0x360
panic({0x100e78ce0?, 0x10106c5a0?})
	/opt/homebrew/Cellar/go/1.21.5/libexec/src/runtime/panic.go:914 +0x218
github.com/mickael-menu/zk/internal/adapter/sqlite.testDBWithFixtures(0x1400005ceb8?, {0x100adedbc?})
	/Users/tjex/.local/src/zk-org/zk.git/fix-collectionDAO-test/internal/adapter/sqlite/transaction_test.go:23 +0x58
github.com/mickael-menu/zk/internal/adapter/sqlite.testTransactionWithFixtures(0x1400005cf18?, {0x100af1960?}, 0x140001e7f18)
	/Users/tjex/.local/src/zk-org/zk.git/fix-collectionDAO-test/internal/adapter/sqlite/transaction_test.go:46 +0x24
github.com/mickael-menu/zk/internal/adapter/sqlite.testTransaction(...)
	/Users/tjex/.local/src/zk-org/zk.git/fix-collectionDAO-test/internal/adapter/sqlite/transaction_test.go:40
github.com/mickael-menu/zk/internal/adapter/sqlite.testCollectionDAO(0xed65ed000000000?, 0x6597c942?)
	/Users/tjex/.local/src/zk-org/zk.git/fix-collectionDAO-test/internal/adapter/sqlite/collection_dao_test.go:121 +0x4c
github.com/mickael-menu/zk/internal/adapter/sqlite.TestCollectionDAOFindOrCreate(0x0?)
	/Users/tjex/.local/src/zk-org/zk.git/fix-collectionDAO-test/internal/adapter/sqlite/collection_dao_test.go:12 +0x34
testing.tRunner(0x14000185040, 0x100ebe130)
	/opt/homebrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1595 +0xe8
created by testing.(*T).Run in goroutine 1
	/opt/homebrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1648 +0x33c
FAIL	github.com/mickael-menu/zk/internal/adapter/sqlite	0.010s

How to reproduce?

run go test ./internal/adapter/sqlite from root of current main branch, commit 50fb638.

Could be because the function FindOrCreate wants to operate on a collection, so just running a test without a db may be what's returning the nil pointer?

@tjex tjex self-assigned this Jan 5, 2024
@mickael-menu
Copy link
Member

Not sure if that helps, but you need to pass the CLI arguments -tags "fts5" to go to enable the FTS with SQLite.

@tjex
Copy link
Member Author

tjex commented Jan 5, 2024

ooh yep. that did it :) Thanks!

@tjex tjex closed this as completed Jan 5, 2024
@tjex
Copy link
Member Author

tjex commented Jan 5, 2024

Ahhh, this is why the tests should be run via make. Saw that before in the Makefile, but it didn't click...

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

No branches or pull requests

2 participants