added crons web apis and ui listing
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package cron
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestJobId(t *testing.T) {
|
||||
expected := "test"
|
||||
@@ -22,8 +25,8 @@ func TestJobExpr(t *testing.T) {
|
||||
|
||||
j := Job{schedule: s}
|
||||
|
||||
if j.Expr() != expected {
|
||||
t.Fatalf("Expected job with cron expression %q, got %q", expected, j.Expr())
|
||||
if j.Expression() != expected {
|
||||
t.Fatalf("Expected job with cron expression %q, got %q", expected, j.Expression())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,3 +50,22 @@ func TestJobRun(t *testing.T) {
|
||||
t.Fatalf("Expected calls %q, got %q", expected, calls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestJobMarshalJSON(t *testing.T) {
|
||||
s, err := NewSchedule("1 2 3 4 5")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
j := Job{id: "test_id", schedule: s}
|
||||
|
||||
raw, err := json.Marshal(j)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := `{"id":"test_id","expression":"1 2 3 4 5"}`
|
||||
if str := string(raw); str != expected {
|
||||
t.Fatalf("Expected\n%s\ngot\n%s", expected, str)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user