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

jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
JohnS
I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps. With: ruby-3.0.0 s...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
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
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
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

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1143 25883 760
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New

Sub Categories: