mirror of
https://github.com/terorie/od-database-crawler.git
synced 2025-12-16 00:19:01 +00:00
Resume tests
This commit is contained in:
48
resume_test.go
Normal file
48
resume_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/terorie/od-database-crawler/fasturl"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestResumeTasks_Empty(t *testing.T) {
|
||||
start := time.Now().Add(-1 * time.Minute)
|
||||
od := OD {
|
||||
Task: Task {
|
||||
WebsiteId: 213,
|
||||
Url: "https://the-eye.eu/public/",
|
||||
},
|
||||
Result: TaskResult {
|
||||
StartTime: start,
|
||||
StartTimeUnix: start.Unix(),
|
||||
EndTimeUnix: time.Now().Unix(),
|
||||
WebsiteId: 213,
|
||||
},
|
||||
InProgress: 0,
|
||||
BaseUri: fasturl.URL {
|
||||
Scheme: fasturl.SchemeHTTPS,
|
||||
Host: "the-eye.eu",
|
||||
Path: "/public/",
|
||||
},
|
||||
}
|
||||
od.WCtx.OD = &od
|
||||
|
||||
var b bytes.Buffer
|
||||
var err error
|
||||
err = writePauseFile(&od, &b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
buf := b.Bytes()
|
||||
|
||||
var od2 OD
|
||||
|
||||
b2 := bytes.NewBuffer(buf)
|
||||
err = readPauseFile(&od2, b2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user