Explorar o código

Add test coverage for Records.isControl() and Records.isPartial()

Vlad Hanciuta %!s(int64=8) %!d(string=hai) anos
pai
achega
6d52b9931e
Modificáronse 1 ficheiros con 32 adicións e 0 borrados
  1. 32 0
      records_test.go

+ 32 - 0
records_test.go

@@ -53,6 +53,22 @@ func TestLegacyRecords(t *testing.T) {
 	if n != 1 {
 		t.Errorf("Wrong number of records, wanted 1, got %d", n)
 	}
+
+	p, err := r.isPartial()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if p {
+		t.Errorf("MessageSet shouldn't have a partial trailing message")
+	}
+
+	c, err := r.isControl()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if c {
+		t.Errorf("MessageSet can't be a control batch")
+	}
 }
 
 func TestDefaultRecords(t *testing.T) {
@@ -102,4 +118,20 @@ func TestDefaultRecords(t *testing.T) {
 	if n != 1 {
 		t.Errorf("Wrong number of records, wanted 1, got %d", n)
 	}
+
+	p, err := r.isPartial()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if p {
+		t.Errorf("RecordBatch shouldn't have a partial trailing record")
+	}
+
+	c, err := r.isControl()
+	if err != nil {
+		t.Fatal(err)
+	}
+	if c {
+		t.Errorf("RecordBatch shouldn't be a control batch")
+	}
 }