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

0 694 0

Where Next?

Popular Pragmatic Bookshelf topics Top

leonW
I ran this command after installing the sample application: $ cards add do something --owner Brian And got a file not found error: Fil...
5 4369 7
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
0 2667 2
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
2 1164 8
New
nicoatridge
Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
0 7996 6
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
5 1406 5
New
dsmith42
Hey there, I’m enjoying this book and have learned a few things alredayd. However, in Chapter 4 I believe we are meant to see the “>...
0 1933 3
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
2 2083 9
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...
0 1761 6
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 ...
6 1112 5
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
0 2059 6
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
201 4638 102
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
30 3963 10
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
10 5616 8
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
190 3839 79
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
37 2727 14
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
15 5398 1
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
21 5598 9
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
16 4113 11
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
0 1782 0
New
AstonJ
This is cool! DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON We just witnessed something incredible: the largest open-s...
0 3570 1
New

Sub Categories: