diff --git a/log_entry_test.go b/log_entry_test.go index 9113aae091..b7a6032750 100644 --- a/log_entry_test.go +++ b/log_entry_test.go @@ -2,7 +2,7 @@ package raft import ( "encoding/json" - //"reflect" + "reflect" "testing" ) @@ -24,14 +24,14 @@ func TestLogEntryMarshal(t *testing.T) { } } -// // Ensure that we can decode a log entry from JSON. -// func TestLogEntryUnmarshal(t *testing.T) { -// e := &LogEntry{} -// b := []byte(`{"command":{"name":"localhost:1000"},"index":1,"name":"test:join","term":2}`) -// if err := json.Unmarshal(b, e); err != nil { -// t.Fatalf("Log entry unmarshalling error: %v", err) -// } -// if !reflect.DeepEqual(e, NewLogEntry(nil, 1, 2, &joinCommand{Name: "localhost:1000"})) { -// t.Fatalf("Log entry unmarshaled incorrectly: %v", e) -// } -// } +// Ensure that we can decode a log entry from JSON. +func TestLogEntryUnmarshal(t *testing.T) { + e := &LogEntry{} + b := []byte(`{"command":{"name":"localhost:1000"},"index":1,"name":"test:join","term":2}`) + if err := json.Unmarshal(b, e); err != nil { + t.Fatalf("Log entry unmarshalling error: %v", err) + } + if !(e.Index == 1 && e.Term == 2 && reflect.DeepEqual(e.Command, &joinCommand{Name: "localhost:1000"})) { + t.Fatalf("Log entry unmarshaled incorrectly: %v | %v", e, NewLogEntry(nil, 1, 2, &joinCommand{Name: "localhost:1000"})) + } +}