git » chasquid » commit f4fb215

protoio: Use keyed fields in composite literal

author Alberto Bertogli
2018-03-02 14:59:27 UTC
committer Alberto Bertogli
2018-03-02 19:37:37 UTC
parent f629ffefa4cfca723b087b438a20e2725851876e

protoio: Use keyed fields in composite literal

In the protoio tests, we were using unkeyed fields in some composite
literals. This can cause confusion and makes the code more brittle wrt.
future changes. go vet also complains about this.

This patch fixes the issue by adding the field names to the struct
initializations.

internal/protoio/protoio_test.go +3 -3

diff --git a/internal/protoio/protoio_test.go b/internal/protoio/protoio_test.go
index c827a84..f917ffb 100644
--- a/internal/protoio/protoio_test.go
+++ b/internal/protoio/protoio_test.go
@@ -11,7 +11,7 @@ import (
 func TestBin(t *testing.T) {
 	dir := testlib.MustTempDir(t)
 	defer testlib.RemoveIfOk(t, dir)
-	pb := &testpb.M{"hola"}
+	pb := &testpb.M{Content: "hola"}
 
 	if err := WriteMessage("f", pb, 0600); err != nil {
 		t.Error(err)
@@ -29,7 +29,7 @@ func TestBin(t *testing.T) {
 func TestText(t *testing.T) {
 	dir := testlib.MustTempDir(t)
 	defer testlib.RemoveIfOk(t, dir)
-	pb := &testpb.M{"hola"}
+	pb := &testpb.M{Content: "hola"}
 
 	if err := WriteTextMessage("f", pb, 0600); err != nil {
 		t.Error(err)
@@ -56,7 +56,7 @@ func TestStore(t *testing.T) {
 		t.Errorf("expected no ids, got %v - %v", ids, err)
 	}
 
-	pb := &testpb.M{"hola"}
+	pb := &testpb.M{Content: "hola"}
 
 	if err := st.Put("f", pb); err != nil {
 		t.Error(err)