Fix TestLogEntryUnmarshal.
parent
2cf93fd102
commit
0aa9a8d145
|
@ -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"}))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue