orlangure/gnomock

Bug: Container is broken

Closed this issue · 6 comments

Describe the bug

i'm working with version v0.18.1
When i'm using gnomock.Container.DefaultAddress() i get panic.
it was working until yesterday and now it always panics.

this is the stack trace:

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=0x1 addr=0x0 pc=0x1c77419]

goroutine 4967 [running]:
testing.tRunner.func1.2({0x539aa80, 0x94df330})
/opt/hostedtoolcache/go/1.18.10/x64/src/testing/testing.go:1389 +0x366
testing.tRunner.func1()
/opt/hostedtoolcache/go/1.18.10/x64/src/testing/testing.go:1392 +0x5d2
panic({0x539aa80, 0x94df330})
/opt/hostedtoolcache/go/1.18.10/x64/src/runtime/panic.go:844 +0x258
github.com/orlangure/gnomock.(*Container).Port(...)
/home/runner/go/pkg/mod/github.com/orlangure/gnomock@v0.18.1/container.go:51
github.com/orlangure/gnomock.(*Container).Address(0x0, {0x59d84bc, 0x7})
/home/runner/go/pkg/mod/github.com/orlangure/gnomock@v0.18.1/container.go:35 +0x39
github.com/orlangure/gnomock.(*Container).DefaultAddress(...)
/home/runner/go/pkg/mod/github.com/orlangure/gnomock@v0.18.1/container.go:45

this is the initialization:
type MyType struct {
Field1 string
}
p := &MyType{Field1: "foobar"}
container, err = gnomock.Start(
p,
gnomock.WithContainerName("vault"),
gnomock.WithUseLocalImagesFirst(),
)

then, this call panics:
container.DefaultAddress()

somehow, version 0.18.1 got broken.

If container is nil, there must be an error. You forgot if err != nil {}

the Container is not nil. see the stack above

According to the stack trace it is nil. You can add an assertion to confirm.

ok, you right, but what can i do to get this container not nil?
you can reproduce it by yourself. gnomock.Start() is broken.

You are jumping to conclusions too quickly, nothing is broken. 4 hours ago tests were successfully executed on an up to date branch. The problem is somewhere in your code. Either come up with exact code that reproduces the issue for everybody, or look for issues with you specific usage.

right. my container ("vault") "latest" version was removed.