objectbox / objectbox-go

Embedded Go Database, the fast alternative to SQLite, gorm, etc.
https://objectbox.io
Apache License 2.0
1.07k stars 46 forks source link

Fresh install fails to run tests #21

Closed tsal closed 4 years ago

tsal commented 4 years ago

ObjectBox looks like it might be a good choice for a personal project, but I'm having some issues getting it to work out of the, er.. box. The install script works fine, but running the go tests throws me a panic, and it looks as if some expected test data is missing.

go 1.13.4 macOS Mojave (10.14.x)

I'm using go modules and ran the install script from my project path - it updated go.mod as I expected:

    github.com/objectbox/objectbox-go v1.1.0 // indirect

Test output:

$ go test github.com/objectbox/objectbox-go/...
?       github.com/objectbox/objectbox-go/cmd/objectbox-gogen   [no test files]
?       github.com/objectbox/objectbox-go/examples/tasks        [no test files]
?       github.com/objectbox/objectbox-go/examples/tasks/internal/model [no test files]
?       github.com/objectbox/objectbox-go/internal/generator    [no test files]
?       github.com/objectbox/objectbox-go/internal/generator/modelinfo  [no test files]
?       github.com/objectbox/objectbox-go/internal/generator/templates  [no test files]
?       github.com/objectbox/objectbox-go/objectbox     [no test files]
ok      github.com/objectbox/objectbox-go/objectbox/fbutils     (cached)
001-14:48:42.5678 [ERROR] Storage error code 13
--- FAIL: TestBoxAsync (0.00s)
panic: Could not create ObjectBox - please check configuration: Dir does not exist: testdata (13) [recovered]
        panic: Could not create ObjectBox - please check configuration: Dir does not exist: testdata (13)

goroutine 35 [running]:
testing.tRunner.func1(0xc000130900)
        /usr/local/go/src/testing/testing.go:874 +0x3a3
panic(0x42f7d00, 0xc0001af2b0)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/objectbox/objectbox-go/objectbox.(*Builder).Build(0xc0001c0640, 0xc0001a8150, 0xc0001c0640, 0x24)
        /redacted/go/pkg/mod/github.com/objectbox/objectbox-go@v1.1.0/objectbox/builder.go:133 +0xdc
github.com/objectbox/objectbox-go/test/model.NewTestEnv(0xc000130900, 0xd0)
        /redacted/go/pkg/mod/github.com/objectbox/objectbox-go@v1.1.0/test/model/testenv.go:54 +0xf8
github.com/objectbox/objectbox-go/test_test.testAsync(0xc000130900, 0x4392270)
        /redacted/go/pkg/mod/github.com/objectbox/objectbox-go@v1.1.0/test/async_test.go:57 +0x43
github.com/objectbox/objectbox-go/test_test.TestBoxAsync(0xc000130900)
        /redacted/go/pkg/mod/github.com/objectbox/objectbox-go@v1.1.0/test/async_test.go:29 +0x37
testing.tRunner(0xc000130900, 0x4392278)
        /usr/local/go/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
        /usr/local/go/src/testing/testing.go:960 +0x350
FAIL    github.com/objectbox/objectbox-go/test  0.022s
?       github.com/objectbox/objectbox-go/test/assert   [no test files]
?       github.com/objectbox/objectbox-go/test/build    [no test files]
--- FAIL: TestGenerator (0.00s)
    --- FAIL: TestGenerator/relations (0.00s)
        test-all.go:67: Testing relations without model info JSON
        assert.go:142: Unexpected error occurred: open testdata/relations/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:79
            test-all.go:52

    --- FAIL: TestGenerator/converters (0.00s)
        test-all.go:67: Testing converters without model info JSON
        test-all.go:177:   runeid.go
        assert.go:142: Unexpected error occurred: can't init ModelInfo: open testdata/converters/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:193
            test-all.go:82
            test-all.go:52

    --- FAIL: TestGenerator/task (0.00s)
        test-all.go:67: Testing task without model info JSON
        test-all.go:177:   bypointer.go
        assert.go:142: Unexpected error occurred: can't init ModelInfo: open testdata/task/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:193
            test-all.go:82
            test-all.go:52

    --- FAIL: TestGenerator/rename-property (0.00s)
        test-all.go:67: Testing rename-property without model info JSON
        assert.go:142: Unexpected error occurred: open testdata/rename-property/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:79
            test-all.go:52

    --- FAIL: TestGenerator/remove-property (0.00s)
        test-all.go:67: Testing remove-property without model info JSON
        assert.go:142: Unexpected error occurred: open testdata/remove-property/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:79
            test-all.go:52

    --- FAIL: TestGenerator/remove-index (0.00s)
        test-all.go:67: Testing remove-index without model info JSON
        assert.go:142: Unexpected error occurred: open testdata/remove-index/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:79
            test-all.go:52

    --- FAIL: TestGenerator/property-update (0.00s)
        test-all.go:67: Testing property-update without model info JSON
        assert.go:142: Unexpected error occurred: open testdata/property-update/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:79
            test-all.go:52

    --- FAIL: TestGenerator/typeful (0.00s)
        test-all.go:67: Testing typeful without model info JSON
        test-all.go:177:   aliases.go
        assert.go:142: Unexpected error occurred: can't init ModelInfo: open testdata/typeful/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:193
            test-all.go:82
            test-all.go:52

    --- FAIL: TestGenerator/rename-relation (0.00s)
        test-all.go:67: Testing rename-relation without model info JSON
        assert.go:142: Unexpected error occurred: open testdata/rename-relation/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:79
            test-all.go:52

    --- FAIL: TestGenerator/rename-entity (0.00s)
        test-all.go:67: Testing rename-entity without model info JSON
        assert.go:142: Unexpected error occurred: open testdata/rename-entity/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:79
            test-all.go:52

    --- FAIL: TestGenerator/intra-package-dependency (0.00s)
        test-all.go:67: Testing intra-package-dependency without model info JSON
        assert.go:142: Unexpected error occurred: open testdata/intra-package-dependency/A.obx.go: permission denied 
             Call stack:
            test-all.go:79
            test-all.go:52

    --- FAIL: TestGenerator/cycles (0.00s)
        test-all.go:67: Testing cycles without model info JSON
        test-all.go:177:   embedding-named.fail.go
        assert.go:142: Values are not equal
            Expected: can't prepare bindings for testdata/cycles/embedding-named.fail.go: embedded struct cycle detected: EmbeddingNamedChainA.BPtr.CPtr on property APtr found in EmbeddingNamedChainA.BPtr.CPtr
            Received: can't init ModelInfo: open testdata/cycles/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:188
            test-all.go:82
            test-all.go:52

    --- FAIL: TestGenerator/id (0.00s)
        test-all.go:67: Testing id without model info JSON
        test-all.go:177:   A.go
        assert.go:142: Unexpected error occurred: can't init ModelInfo: open testdata/id/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:193
            test-all.go:82
            test-all.go:52

    --- FAIL: TestGenerator/negative (0.00s)
        test-all.go:67: Testing negative without model info JSON
        test-all.go:177:   duplicate-property.fail.go
        assert.go:142: Values are not equal
            Expected: can't prepare bindings for testdata/negative/duplicate-property.fail.go: duplicate name (note that property names are case insensitive) on property text found in DuplicateProperty
            Received: can't init ModelInfo: open testdata/negative/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:188
            test-all.go:82
            test-all.go:52

    --- FAIL: TestGenerator/embedding (0.00s)
        test-all.go:67: Testing embedding without model info JSON
        test-all.go:177:   1.fail.go
        assert.go:142: Values are not equal
            Expected: can't prepare bindings for testdata/embedding/1.fail.go: duplicate name (note that property names are case insensitive) on property Value found in Negative1.BytesValue
            Received: can't init ModelInfo: open testdata/embedding/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:188
            test-all.go:82
            test-all.go:52

    --- FAIL: TestGenerator/multi-files (0.00s)
        test-all.go:67: Testing multi-files without model info JSON
        test-all.go:177:   A.go
        assert.go:142: Unexpected error occurred: can't init ModelInfo: open testdata/multi-files/objectbox-model.json: permission denied 
             Call stack:
            test-all.go:193
            test-all.go:82
            test-all.go:52

FAIL
FAIL    github.com/objectbox/objectbox-go/test/generator        0.027s
?       github.com/objectbox/objectbox-go/test/model    [no test files]
?       github.com/objectbox/objectbox-go/test/model/iot        [no test files]
2020/02/10 09:48:42 running the test with 100000 objects
001-14:48:42.5023 [ERROR] Storage error code 13
--- FAIL: TestPerformanceSimple (0.00s)
panic: Could not create ObjectBox - please check configuration: Dir does not exist: db (13) [recovered]
        panic: Could not create ObjectBox - please check configuration: Dir does not exist: db (13)

goroutine 36 [running]:
testing.tRunner.func1(0xc00012a800)
        /usr/local/go/src/testing/testing.go:874 +0x3a3
panic(0x424eee0, 0xc0001d40c0)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/objectbox/objectbox-go/objectbox.(*Builder).Build(0xc000185880, 0xc0001f0000, 0xc000185880, 0xc0000ca000)
        /redacted/go/pkg/mod/github.com/objectbox/objectbox-go@v1.1.0/objectbox/builder.go:133 +0xdc
github.com/objectbox/objectbox-go/test/performance.(*executor).initObjectBox(0xc0000edf48, 0x42b8f0c, 0x2)
        /redacted/go/pkg/mod/github.com/objectbox/objectbox-go@v1.1.0/test/performance/perf.go:45 +0x11c
github.com/objectbox/objectbox-go/test/performance.createExecutor(...)
        /redacted/go/pkg/mod/github.com/objectbox/objectbox-go@v1.1.0/test/performance/perf.go:38
github.com/objectbox/objectbox-go/test/performance.TestPerformanceSimple(0xc00012a800)
        /redacted/go/pkg/mod/github.com/objectbox/objectbox-go@v1.1.0/test/performance/perf_test.go:39 +0x19f
testing.tRunner(0xc00012a800, 0x42cebb8)
        /usr/local/go/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
        /usr/local/go/src/testing/testing.go:960 +0x350
FAIL    github.com/objectbox/objectbox-go/test/performance      0.023s
?       github.com/objectbox/objectbox-go/test/performance/perf [no test files]
FAIL

Test main.go:

package main

func main() {}

//go:generate go run github.com/objectbox/objectbox-go/cmd/objectbox-gogen

​type Task struct {
    Id   uint64
    Text string
}

Go generate execution:

go generate ./...
Generating ObjectBox bindings for main.go
can't parse GO file main.go: main.go:25:1: illegal character U+200B
exit status 2
main.go:23: running "go": exit status 1

I thought it was kinda weird that it had an install script with some build steps happening - is this not the correct instructions for using this as an embedded engine?

vaind commented 4 years ago

I can reproduce the test issue when running go test github.com/objectbox/objectbox-go/... - I'll have a look what's the problem.

However, I suggest you can still go ahead and use ObjectBox in your project, it should work on your version of macOS AFAICT.

The problem with your main.go is unrelated to ObjectBox and actually says it in the error: illegal character U+200B - looks like your main.go has 0-width spaces at the beginning of line 25 - try to remove those. Googling that error yielded some, probably useful, suggestions, e.g.

https://stackoverflow.com/questions/35657620/illegal-character-error-u200b
You should delete line 12 (the blank line), save the file, re-add the blank line and save again. using a simple text editor. If that doesn't fix it delete lines 11 and 13 as well and recreate them.

vaind commented 4 years ago

Test failure fixed by by the latest release v1.1.1