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

jimschubert
In Chapter 3, the source for index introduces Config on page 31, followed by more code including tests; Config isn’t introduced until pag...
New
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
Mmm
Hi, build fails on: bracket-lib = “~0.8.1” when running on Mac Mini M1 Rust version 1.5.0: Compiling winit v0.22.2 error[E0308]: mi...
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
hazardco
On page 78 the following code appears: <%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
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

Other popular topics Top

dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
PragmaticBookshelf
Tailwind CSS is an exciting new CSS framework that allows you to design your site by composing simple utility classes to create complex e...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
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
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New

Sub Categories: