elesq

elesq

Distributed Services with Go: 'make tests' fails on testProduceConsume (code matches at this stage) page 132

@travisjeffery

As per instructions up to page 132, I have checked the code against the downloadable resources and A/B’d back and forth. Everything appears to be in good shape. At this point, it tells me to update the NewGRPCServer function and then I can run make test and everything will pass as before. Unfortunately, the tests are failing.

 make test
go test -race ./...
?       github.com/myusername/proglog/api/v1 [no test files]
?       github.com/myusername/proglog/cmd/server     [no test files]
?       github.com/myusername/proglog/internal/config        [no test files]
ok      github.com/myusername/proglog/internal/log   (cached)
--- FAIL: TestServer (0.00s)
    --- FAIL: TestServer/produce/consume_a_message_to/from_the_log_succeeds (0.00s)
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=0x28 pc=0x17a26a3]

goroutine 20 [running]:
testing.tRunner.func1.2(0x1817ae0, 0x1ccd540)
        /usr/local/Cellar/go/1.16.6/libexec/src/testing/testing.go:1143 +0x49f
testing.tRunner.func1(0xc000082d80)
        /usr/local/Cellar/go/1.16.6/libexec/src/testing/testing.go:1146 +0x695
panic(0x1817ae0, 0x1ccd540)
        /usr/local/Cellar/go/1.16.6/libexec/src/runtime/panic.go:971 +0x499
github.com/elesq/proglog/internal/server.testProduceConsume(0xc000082d80, 0x0, 0x0, 0xc00017e530)
        /Users/ed/code/myusername/go/book-distributed-services-with-go/proglog/internal/server/server_test.go:107 +0x1e3
github.com/myusername/proglog/internal/server.TestServer.func1(0xc000082d80)
        /Users/ed/code/myusername/go/book-distributed-services-with-go/proglog/internal/server/server_test.go:34 +0x118
testing.tRunner(0xc000082d80, 0xc00009bcf0)
        /usr/local/Cellar/go/1.16.6/libexec/src/testing/testing.go:1193 +0x203
created by testing.(*T).Run
        /usr/local/Cellar/go/1.16.6/libexec/src/testing/testing.go:1238 +0x5d8
FAIL    github.com/myusername/proglog/internal/server        0.482s
FAIL
make: *** [test] Error 1

Check the testcase shows my code is the same as the book and repo. Any ideas?

serve_test.go:107

produce, err := client.Produce(
		ctx,
		&api.ProduceRequest{
			Record: want,
		},
	)
	require.NoError(t, err)

and server_test:34

t.Run(scenario, func(t *testing.T) {
			client,
				config,
				teardown := setupTest(t, nil)
			defer teardown()

			fn(t, client, config) // this is line 34
		})

Cheers

Where Next?

Popular Pragmatic Bookshelf topics Top

conradwt
First, the code resources: Page 237: rumbl_umbrella/apps/rumbl/mix.exs Note: That this file is missing. Page 238: rumbl_umbrella/app...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
New
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New

Other popular topics Top

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New

Sub Categories: