N
N
nightblaze2016-10-25 19:51:53
go
nightblaze, 2016-10-25 19:51:53

How to test in Golang?

Hello!
There is a method for sending data to a channel

func (c *Connection) SendMessage(message []byte) {
  c.send <- message
}

What is the right way to write a unit test for it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2016-10-25
@nightblaze

There is no need to write a unit test for it, because this method is quite trivial.
PS If we still wrote a test for it, we would create a Connection object in the test, initialize a channel for it, and check whether a message is written there by reading the channel.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question