Esempio n. 1
0
func TestRecord(t *testing.T) {
	f, _ := os.Open("testdata/test.warc.gz")
	gz, _ := gzip.NewReader(f)

	reader := warc.NewWarcReader(gz)
	rec, err := reader.ReadRecord()
	if err != nil {
		t.Error(err)
	}
	assert.Equal(t, rec.Version, "WARC/1.0")
	assert.Equal(t, len(rec.Headers), 7)
	assert.Equal(t, rec.Headers["content-length"], "251")
	assert.Equal(t, rec.ContentBlockStart, int64(278))
	assert.Equal(t, rec.ContentBlockEnd, int64(529))
}
Esempio n. 2
0
func TestReader(t *testing.T) {
	f, _ := os.Open("testdata/test.warc.gz")
	gz, _ := gzip.NewReader(f)
	reader := warc.NewWarcReader(gz)
	count := 0
	for {
		rec, err := reader.ReadRecord()
		if rec == nil {
			break
		}
		if err != nil {
			t.Error("received error from ReadRecord", err)
		}
		count += 1
	}
	assert.Equal(t, count, 10)
}