Skip to content

Commit

Permalink
fix: fix Difference with empty log
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddi committed Jun 12, 2019
1 parent d37a8de commit 724915c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package log

import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -386,10 +384,12 @@ func (l *Log) Join(otherLog *Log, size int) (*Log, error) {
}

func Difference(logA, logB *Log) *entry.OrderedMap {
if logA == nil || logA.Entries == nil || len(logA.Entries.Keys()) == 0 {
return logB.Entries
} else if logB == nil || logB.Entries == nil || len(logB.Entries.Keys()) == 0 {
return logA.Entries
if logA == nil || logA.Entries == nil || logA.Entries.Len() == 0 || logB == nil {
return entry.NewOrderedMap()
}

if logB.Entries == nil {
logB.Entries = entry.NewOrderedMap()
}

stack := logA.heads.Keys()
Expand Down
4 changes: 0 additions & 4 deletions test/entry_io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ import (
. "github.com/smartystreets/goconvey/convey"
)

func intPtr(val int) *int {
return &val
}

func TestEntryPersistence(t *testing.T) {
_, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
Expand Down
4 changes: 4 additions & 0 deletions test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ func minInt(a, b int) int {
}
return b
}

func intPtr(val int) *int {
return &val
}

0 comments on commit 724915c

Please sign in to comment.