Closed diabloneo closed 3 years ago
The SetType() function allows application code using this library to create unittest code by constructing a object of specific message type.
Signed-off-by: diabloneo diabloneo@gmail.com
Because the Parse() function returns an interface type Message which has a method tells message type. The application may has the form:
Parse()
Message
func processWALMessage(msg pglogrepl.Message) (err error) { switch msg.Type() { case pglogrepl.MessageTypeInsert: ... } return nil }
So, the way to write unittest code for the function requires setting message type explicitly which has not supported yet. After adding the method, the unittest code can wirte like this:
func TestProcessWALMessage(t *testing.T) { msg := &pglogrepl.InsertMessage{ RelationID: 16789, Tuple: &pglogrepl.TupleData{}, } msg.SetType(pglogrepl.MessageTypeInsert) err := processWALMessage(msg) ... }
The SetType() function allows application code using this library to create unittest code by constructing a object of specific message type.
Signed-off-by: diabloneo diabloneo@gmail.com
Because the
Parse()
function returns an interface typeMessage
which has a method tells message type. The application may has the form:So, the way to write unittest code for the function requires setting message type explicitly which has not supported yet. After adding the method, the unittest code can wirte like this: