package main import ( "bytes" "testing" ) func TestPrintMessage(t *testing.T) { buffer := bytes.Buffer{} printMessage(&buffer, "Hello MQTT\n") got := buffer.String() want := "Hello MQTT\n" if got != want { t.Errorf("Error. Got %s but wanted %s", got, want) } }