agent_test.go 1.28 KB
Newer Older
ale's avatar
ale committed
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
package tabacco

import (
	"context"
	"testing"

	"git.autistici.org/ale/tabacco/jobs"
)

type fakeManager struct{}

func (m *fakeManager) BackupJob(context.Context, []SourceSpec) (Backup, jobs.Job, error) {
	return Backup{}, nil, nil
}

func (m *fakeManager) Backup(context.Context, []SourceSpec) (Backup, error) {
	return Backup{}, nil
}

func (m *fakeManager) RestoreJob(context.Context, FindRequest, string) (jobs.Job, error) {
	return nil, nil
}

func (m *fakeManager) Restore(context.Context, FindRequest, string) error {
	return nil
}

func (m *fakeManager) Close() error {
	return nil
}

func (m *fakeManager) GetStatus() ([]jobs.Status, []jobs.Status, []jobs.Status) {
	return nil, nil, nil
}

func TestMakeSchedule(t *testing.T) {
	sourceSpecs := []SourceSpec{
		{
			Name:     "source1",
			Handler:  "file1",
			Schedule: "@random_every 1d",
			Atoms: []Atom{
				{
					Name:         "user1",
					RelativePath: "user1",
				},
				{
					Name:         "user2",
					RelativePath: "user2",
				},
			},
		},
		{
			Name:         "source2",
			Handler:      "dbpipe",
			Schedule:     "35 3 * * *",
			AtomsCommand: "echo user1 user1 ; echo user2 user2",
		},
	}

	mgr := &fakeManager{}
	_, err := makeSchedule(context.Background(), mgr, sourceSpecs, 1234)
	if err != nil {
		t.Fatal(err)
	}
}