learn-go-with-tests
learn-go-with-tests copied to clipboard
context.md assertWasCancelled() and assertWasNotCancelled
Hello, Not sure if I'm simply misunderstanding the following. The text reads:
type SpyStore struct {
response string
cancelled bool
t *testing.T
}
func (s *SpyStore) assertWasCancelled() {
s.t.Helper()
if !s.cancelled {
s.t.Error("store was not told to cancel")
}
}
func (s *SpyStore) assertWasNotCancelled() {
s.t.Helper()
if s.cancelled {
s.t.Error("store was told to cancel")
}
}
Should the Errors be reversed? In the text, it seems like it is saying "if not cancelled, throw an error because the store was not told to cancel". Is it intended to say: "if not cancelled, throw an error because the store was told to cancel"?
type SpyStore struct {
response string
cancelled bool
t *testing.T
}
func (s *SpyStore) assertWasCancelled() {
s.t.Helper()
if !s.cancelled {
s.t.Error("store was told to cancel")
}
}
func (s *SpyStore) assertWasNotCancelled() {
s.t.Helper()
if s.cancelled {
s.t.Error("store was not told to cancel")
}
}
Thanks for your time
I don't think so? If I have assertWasCancelled in my test, and it didn't, I'd expect to see store was not told to cancel