-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain_test.go
71 lines (56 loc) · 1.79 KB
/
main_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
//+build integration
package main_test
import (
"flag"
"os"
"testing"
"github.com/cucumber/messages-go/v10"
"github.com/cucumber/godog"
"github.com/cucumber/godog/colors"
"github.com/gojek/stevedore/internal/cli/helm"
"github.com/gojek/stevedore/internal/helpers"
)
func iHaveAKubernetesClusterWithNameAndVersion(clusterName, version string) error {
return helpers.CreateCluster(clusterName, version, false)
}
func iHaveToInstallIntoMyCluster(_ string, _ string, _ string) error {
return godog.ErrPending
}
func iHaveFollowingHelmRepos(helmRepos *messages.PickleStepArgument_PickleTable) error {
repos := helm.NewRepos(helmRepos)
return helpers.AddHelmRepos(repos)
}
func iRefreshHelmLocalCache() error {
return helpers.UpdateHelmRepo()
}
func InitializeTestSuite(ctx *godog.TestSuiteContext) {
ctx.BeforeSuite(func() {})
}
func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.BeforeScenario(func(*godog.Scenario) {})
ctx.Step(`^I have a kubernetes cluster with name "([^"]*)" and version "([^"]*)"$`, iHaveAKubernetesClusterWithNameAndVersion)
ctx.Step(`^I have following helm repos:$`, iHaveFollowingHelmRepos)
ctx.Step(`^I refresh helm local cache$`, iRefreshHelmLocalCache)
ctx.Step(`^I have to install "([^"]*)" into cluster "([^"]*)" as "([^"]*)"$`, iHaveToInstallIntoMyCluster)
}
var opts = godog.Options{
Output: colors.Colored(os.Stdout),
Format: "progress", // can define default values
}
func init() {
godog.BindFlags("godog.", flag.CommandLine, &opts)
}
func TestMain(m *testing.M) {
flag.Parse()
opts.Paths = flag.Args()
status := godog.TestSuite{
Name: "godogs",
TestSuiteInitializer: InitializeTestSuite,
ScenarioInitializer: InitializeScenario,
Options: &opts,
}.Run()
if st := m.Run(); st > status {
status = st
}
os.Exit(status)
}