Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
KOGITO-4241 Setup godog 0.11 (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
radtriste committed Jan 25, 2021
1 parent ab2f29a commit 617f387
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 26 deletions.
7 changes: 4 additions & 3 deletions cmd/kogito/command/deploy/delete_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ package deploy

import (
"fmt"
"testing"

"github.com/kiegroup/kogito-cloud-operator/api/v1beta1"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/context"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/test"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"
)

func Test_DeleteServiceCmd_SuccessfullyDelete(t *testing.T) {
Expand All @@ -44,7 +45,7 @@ func Test_DeleteServiceCmd_Failure_ServiceDoesNotExist(t *testing.T) {
test.SetupCliTest(cli,
context.CommandFactory{BuildCommands: BuildCommands},
&corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}})
lines, _, err := test.ExecuteCli()
_, errLines, err := test.ExecuteCli()
assert.Error(t, err)
assert.Contains(t, lines, "with the name 'example-drools' doesn't exist")
assert.Contains(t, errLines, "with the name 'example-drools' doesn't exist")
}
11 changes: 6 additions & 5 deletions cmd/kogito/command/deploy/deploy_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ package deploy

import (
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/kiegroup/kogito-cloud-operator/api/v1beta1"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/context"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/test"
Expand All @@ -24,11 +28,8 @@ import (
test2 "github.com/kiegroup/kogito-cloud-operator/pkg/test"
v1 "github.com/openshift/api/build/v1"
"github.com/stretchr/testify/assert"
"io/ioutil"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"os"
"testing"
)

func Test_DeployServiceCmd_DefaultConfigurations(t *testing.T) {
Expand Down Expand Up @@ -153,13 +154,13 @@ func Test_DeployCmd_SWFile(t *testing.T) {
AddBuildObjects(&v1.BuildConfig{ObjectMeta: metav1.ObjectMeta{Name: "serverless-workflow-greeting-quarkus-builder", Namespace: ns}}).
Build())

lines, _, err := test.ExecuteCli()
lines, errLines, err := test.ExecuteCli()
assert.Error(t, err)
assert.Contains(t, lines, "Kogito Build Service successfully installed in the Project")
assert.Contains(t, lines, "File(s) found: testdata/greetings.sw.json")
assert.Contains(t, lines, "Triggering the new build")
// error from fake build is ok, we don't have a server to upload the binaries here.
assert.Contains(t, lines, "v1.BinaryBuildRequestOptions is not suitable for converting")
assert.Contains(t, errLines, "v1.BinaryBuildRequestOptions is not suitable for converting")

kogitoBuild := &v1beta1.KogitoBuild{
ObjectMeta: metav1.ObjectMeta{Name: "serverless-workflow-greeting-quarkus", Namespace: ns},
Expand Down
7 changes: 4 additions & 3 deletions cmd/kogito/command/project/delete_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ package project

import (
"fmt"
"testing"

"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/context"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/test"
"testing"

"github.com/stretchr/testify/assert"

Expand All @@ -45,7 +46,7 @@ func Test_DeleteProjectCmd_WhenProjectDoesNotExist(t *testing.T) {
ns := t.Name()
cli := fmt.Sprintf("delete-project %s", ns)
test.SetupCliTest(cli, context.CommandFactory{BuildCommands: BuildCommands})
lines, _, err := test.ExecuteCli()
_, errLines, err := test.ExecuteCli()
assert.Error(t, err)
assert.Contains(t, lines, fmt.Sprintf("Project %s not found", ns))
assert.Contains(t, errLines, fmt.Sprintf("Project %s not found", ns))
}
7 changes: 4 additions & 3 deletions cmd/kogito/command/project/new_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ package project

import (
"fmt"
"testing"

"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/context"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/message"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/test"
"testing"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -106,7 +107,7 @@ func TestNewProject_WhenTheresNoNamedFlag(t *testing.T) {
func TestNewProject_WhenTheresNoName(t *testing.T) {
cli := "new-project"
test.SetupCliTest(cli, context.CommandFactory{BuildCommands: BuildCommands})
lines, _, err := test.ExecuteCli()
_, errLines, err := test.ExecuteCli()
assert.Error(t, err)
assert.Contains(t, lines, "Please set a project for new-project")
assert.Contains(t, errLines, "Please set a project for new-project")
}
7 changes: 4 additions & 3 deletions cmd/kogito/command/remove/kogitoinfra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ package remove

import (
"fmt"
"testing"

"github.com/kiegroup/kogito-cloud-operator/api/v1beta1"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/context"
"github.com/kiegroup/kogito-cloud-operator/cmd/kogito/command/test"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"
)

func Test_DeleteKogitoInfraCmd_SuccessfullyDelete(t *testing.T) {
Expand All @@ -44,7 +45,7 @@ func Test_DeleteKogitoInfraCmd_Failure_ServiceDoesNotExist(t *testing.T) {
test.SetupCliTest(cli,
context.CommandFactory{BuildCommands: BuildCommands},
&corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ns}})
lines, _, err := test.ExecuteCli()
_, errLines, err := test.ExecuteCli()
assert.Error(t, err)
assert.Contains(t, lines, "kogito Infra resource with name kafka-infra not found")
assert.Contains(t, errLines, "kogito Infra resource with name kafka-infra not found")
}
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require (
github.com/RHsyseng/operator-utils v0.0.0-20200304191317-2425bf382482
github.com/coreos/prometheus-operator v0.40.0
github.com/cucumber/gherkin-go/v11 v11.0.0
github.com/cucumber/godog v0.10.0
github.com/cucumber/godog v0.11.0
github.com/cucumber/messages-go/v10 v10.0.3
github.com/go-logr/logr v0.1.0
github.com/go-logr/zapr v0.1.1
Expand All @@ -23,7 +23,8 @@ require (
github.com/openshift/client-go v0.0.0-20200116152001-92a2713fa240
github.com/operator-framework/operator-lifecycle-manager v0.0.0-20200321030439-57b580e57e88
github.com/operator-framework/operator-marketplace v0.0.0-20190919183128-4ef67b2f50e9
github.com/spf13/cobra v1.0.0
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.6.1
go.uber.org/zap v1.15.0
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 // indirect
Expand Down
22 changes: 18 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cucumber/gherkin-go/v11 v11.0.0 h1:cwVwN1Qn2VRSfHZNLEh5x00tPBmZcjATBWDpxsR5Xug=
github.com/cucumber/gherkin-go/v11 v11.0.0/go.mod h1:CX33k2XU2qog4e+TFjOValoq6mIUq0DmVccZs238R9w=
github.com/cucumber/godog v0.10.0 h1:W01u1+o8bRpgqJRLrclN3iAanU1jAao+TwOMoSV9g1Y=
github.com/cucumber/godog v0.10.0/go.mod h1:0Q+MOUg8Z9AhzLV+nNMbThQ2x1b17yYwGyahApTLjJA=
github.com/cucumber/godog v0.11.0 h1:xgaWyJuAD6A+aW4TfVGNDBhuMyKW0jjl0cvY3KNxEak=
github.com/cucumber/godog v0.11.0/go.mod h1:GyxCIrsg1sgEgpL2GD/rMr3fIoNHpgkjm9nANw/89XY=
github.com/cucumber/messages-go/v10 v10.0.1/go.mod h1:kA5T38CBlBbYLU12TIrJ4fk4wSkVVOgyh7Enyy8WnSg=
github.com/cucumber/messages-go/v10 v10.0.3 h1:m/9SD/K/A15WP7i1aemIv7cwvUw+viS51Ui5HBw1cdE=
github.com/cucumber/messages-go/v10 v10.0.3/go.mod h1:9jMZ2Y8ZxjLY6TG2+x344nt5rXstVVDYSdS5ySfI1WY=
Expand Down Expand Up @@ -712,6 +712,8 @@ github.com/gofrs/flock v0.0.0-20190320160742-5135e617513b/go.mod h1:F1TvTiK9OcQq
github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down Expand Up @@ -935,8 +937,10 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh
github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.2.0 h1:l6UW37iCXwZkZoAbEYnptSHVE/cQ5bOTPYG5W3vf9+8=
github.com/hashicorp/go-immutable-radix v1.2.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-memdb v1.2.1 h1:wI9btDjYUOJJHTCnRlAG/TkRyD/ij7meJMrLK9X31Cc=
github.com/hashicorp/go-memdb v1.2.1/go.mod h1:OSvLJ662Jim8hMM+gWGyhktyWk2xPCnWMc7DWIqtkGA=
github.com/hashicorp/go-immutable-radix v1.3.0 h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE=
github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-memdb v1.3.0 h1:xdXq34gBOMEloa9rlGStLxmfX/dyIK8htOv36dQUwHU=
github.com/hashicorp/go-memdb v1.3.0/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
Expand All @@ -955,6 +959,8 @@ github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdv
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE=
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
Expand Down Expand Up @@ -1107,6 +1113,8 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.0.0/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
Expand Down Expand Up @@ -1605,6 +1613,8 @@ github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHN
github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down Expand Up @@ -2365,6 +2375,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
Expand Down Expand Up @@ -2422,6 +2434,8 @@ gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200603094226-e3079894b1e8 h1:jL/vaozO53FMfZLySWM+4nulF3gQEC6q5jH90LPomDo=
gopkg.in/yaml.v3 v3.0.0-20200603094226-e3079894b1e8/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.1.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/gotestsum v0.3.5/go.mod h1:Mnf3e5FUzXbkCfynWBGOwLssY7gTQgCHObK9tMpAriY=
Expand Down
3 changes: 2 additions & 1 deletion test/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package config

import (
"flag"
"path/filepath"

"github.com/kiegroup/kogito-cloud-operator/pkg/version"

flag "github.com/spf13/pflag"
)

// TestConfig contains the information about the tests environment
Expand Down
5 changes: 3 additions & 2 deletions test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package test

import (
"flag"
"fmt"
"io"
"os"
Expand All @@ -29,6 +28,8 @@ import (
"github.com/kiegroup/kogito-cloud-operator/test/config"
"github.com/kiegroup/kogito-cloud-operator/test/framework"
"github.com/kiegroup/kogito-cloud-operator/test/steps"

flag "github.com/spf13/pflag"
)

const (
Expand All @@ -50,8 +51,8 @@ var (
)

func init() {
godog.BindFlags("godog.", flag.CommandLine, &godogOpts)
config.BindFlags(flag.CommandLine)
godog.BindCommandLineFlags("godog.", &godogOpts)
}

func TestMain(m *testing.M) {
Expand Down

0 comments on commit 617f387

Please sign in to comment.