November 2018
Intermediate to advanced
346 pages
8h 12m
English
Let's apply monkey patching to our ACME registration service that we introduced in Chapter 4, Introduction to ACME Registration Service. One of the many things we would like to improve with our service is the test reliability and coverage. In this case, we will be working on the data package. Currently, we only have one test, and it looks like this:
func TestData_happyPath(t *testing.T) { in := &Person{ FullName: "Jake Blues", Phone: "01234567890", Currency: "AUD", Price: 123.45, } // save resultID, err := Save(in) require.Nil(t, err) assert.True(t, resultID > 0) // load returned, err := Load(resultID) require.NoError(t, err) in.ID = resultID assert.Equal(t, in, returned) // load all all, err := LoadAll() require ...
Read now
Unlock full access