-
Notifications
You must be signed in to change notification settings - Fork 8
/
jobs_test.go
executable file
·48 lines (36 loc) · 1.11 KB
/
jobs_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"encoding/json"
"fmt"
"labix.org/v2/mgo"
"testing"
)
func TestJobs(t *testing.T) {
const MONGO_URL = "localhost"
// Setup the database
session, err := mgo.Dial(MONGO_URL)
if err != nil {
panic(err)
}
defer session.Close()
session.SetMode(mgo.Monotonic, true)
// Insert data into the database
job_file := []byte("72db86e4c73b9fabb4810562b236488e")
job := createJob(3, 0, job_file, "?d?d?d?d", session.Copy())
jobJson, err := json.Marshal(&job)
if err != nil {
t.Errorf("Error creating json for job (%s)", job)
}
expectJobString := "{\"Id\":9,\"AttackMode\":3,\"HashType\":0,\"HashFile\":\"NzJkYjg2ZTRjNzNiOWZhYmI0ODEwNTYyYjIzNjQ4OGU=\",\"Mask\":\"?d?d?d?d\",\"Start\":1,\"Finish\":1000}"
if string(jobJson) != expectJobString {
t.Errorf("CreateJob (%s) doesn't match expected string (%s).", string(jobJson), expectJobString)
}
fmt.Println("Pre-Tast")
// fmt.Println(job)
// fmt.Println("Post-Task")
postJob := loadJob(job.Id, session.Copy())
// fmt.Println(postJob)
if &job != postJob {
t.Errorf("Local Job (%s) and Remote Job (%s) don't match.", &job, postJob)
}
}