-
Notifications
You must be signed in to change notification settings - Fork 0
/
acceptance_test.go
73 lines (64 loc) · 2.94 KB
/
acceptance_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"os"
"testing"
"github.com/cucumber/godog"
"github.com/taciomcosta/kronos/internal/config"
"github.com/taciomcosta/kronos/internal/interfaces/sqlite"
uc "github.com/taciomcosta/kronos/internal/usecases"
"github.com/taciomcosta/kronos/internal/usecases/mocker"
spyhost "github.com/taciomcosta/kronos/internal/usecases/mocker/spy_host"
"github.com/taciomcosta/kronos/test"
)
var host *spyhost.SpyHost
func TestMain(m *testing.M) {
status := godog.TestSuite{
Name: "jobs",
TestSuiteInitializer: InitializeTestSuite,
ScenarioInitializer: InitializeScenario,
}.Run()
os.Exit(status)
}
func InitializeTestSuite(ctx *godog.TestSuiteContext) {
ctx.BeforeSuite(func() {
config.EnableTestMode()
writerReader := sqlite.NewWriterReader(config.GetString("db"))
host = mocker.Dependencies().Host().Build()
dependencies := uc.Dependencies{
Writer: writerReader,
Reader: writerReader,
Host: host,
NotifierService: mocker.Dependencies().NotifierService().Build(),
}
uc.New(dependencies)
})
}
func InitializeScenario(ctx *godog.ScenarioContext) {
jf := features.JobsFeature{}
ctx.Step(`^I provide valid data for job creation$`, jf.IProvideValidDataForJobCreation)
ctx.Step(`^I create a new job$`, jf.ICreateANewJob)
ctx.Step(`^I list the existing jobs$`, jf.IListTheExistingJobs)
ctx.Step(`^the new job is listed$`, jf.TheNewJobIsListed)
ctx.Step(`^an error message is shown for job$`, jf.AnErrorMessageIsShownForJob)
ctx.Step(`^I provide invalid data for job creation$`, jf.IProvideInvalidDataForJobCreation)
ctx.Step(`^I delete the new job$`, jf.IDeleteTheNewJob)
ctx.Step(`^the new job is not listed$`, jf.TheNewJobIsNotListed)
ctx.Step(`^I describe the new job$`, jf.IDescribeTheNewJob)
ctx.Step(`^the new job is detailed$`, jf.TheNewJobIsDetailed)
ef := features.ExecutionsFeature{Host: host}
ctx.Step(`^(\d+) execution is listed$`, ef.ExecutionIsListed)
ctx.Step(`^I list all job execution history$`, ef.IListAllJobExecutionHistory)
ctx.Step(`^that I create a job$`, ef.ThatICreateAJob)
ctx.Step(`^the job finishes (\d+) execution$`, ef.TheJobFinishesExecution)
nf := features.NotifiersFeature{}
ctx.Step(`^I provide valid data for notifier creation$`, nf.IProvideValidDataForNotifierCreation)
ctx.Step(`^I create a new notifier$`, nf.ICreateANewNotifier)
ctx.Step(`^I list the existing notifiers$`, nf.IListTheExistingNotifiers)
ctx.Step(`^the new notifier is listed$`, nf.TheNewNotifierIsListed)
ctx.Step(`^an error message is shown for notifier$`, nf.AnErrorMessageIsShownForNotifier)
ctx.Step(`^I provide invalid data for notifier creation$`, nf.IProvideInvalidDataForNotifierCreation)
ctx.Step(`^I delete the new notifier$`, nf.IDeleteTheNewNotifier)
ctx.Step(`^the new notifier is not listed$`, nf.TheNewNotifierIsNotListed)
ctx.Step(`^I describe the new notifier$`, nf.IDescribeTheNewNotifier)
ctx.Step(`^the new notifier is detailed$`, nf.TheNewNotifierIsDetailed)
}