|
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|
|
package wal
|
|
|
|
|
|
import (
|
|
|
+ "bytes"
|
|
|
"fmt"
|
|
|
"io/ioutil"
|
|
|
"os"
|
|
|
@@ -322,3 +323,17 @@ func TestRecoverAfterCut(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestSaveEmpty(t *testing.T) {
|
|
|
+ var buf bytes.Buffer
|
|
|
+ var est raftpb.State
|
|
|
+ w := WAL{
|
|
|
+ encoder: newEncoder(&buf, 0),
|
|
|
+ }
|
|
|
+ if err := w.SaveState(&est); err != nil {
|
|
|
+ t.Errorf("err = %v, want nil", err)
|
|
|
+ }
|
|
|
+ if len(buf.Bytes()) != 0 {
|
|
|
+ t.Errorf("buf.Bytes = %d, want 0", len(buf.Bytes()))
|
|
|
+ }
|
|
|
+}
|