Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split "servicecatalog" module in UI API Layer Acceptance tests #2168

Merged
merged 7 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/ui-api-layer-acceptance-tests/internal/dex/dex.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ import (

const sciEnabledMessage = "SCI is enabled"

func SkipTestIfShould(t *testing.T) {
func SkipTestIfSCIEnabled(t *testing.T) {
if !isSCIEnabled() {
return
}

t.Skip(sciEnabledMessage)
}

func SkipMainIfShould() {
func ExitIfSCIEnabled() {
if !isSCIEnabled() {
pkosiec marked this conversation as resolved.
Show resolved Hide resolved
return
}

log.Println(sciEnabledMessage)
os.Exit(0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type applicationEvent struct {
}

func TestApplicationMutations(t *testing.T) {
dex.SkipTestIfShould(t)
dex.SkipTestIfSCIEnabled(t)

c, err := graphql.New()
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type idpPresetDeleteMutationResponse struct {
}

func TestIDPPresetQueriesAndMutations(t *testing.T) {
dex.SkipTestIfShould(t)
dex.SkipTestIfSCIEnabled(t)

c, err := graphql.New()
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
)

func TestLimitRangeQuery(t *testing.T) {
dex.SkipTestIfShould(t)
dex.SkipTestIfSCIEnabled(t)

c, err := graphql.New()
require.NoError(t, err)
Expand All @@ -46,13 +46,14 @@ func TestLimitRangeQuery(t *testing.T) {
_, err = client.LimitRanges(limitRangeNamespace).Create(fixLimitRange())
require.NoError(t, err)

waiter.WaitAtMost(func() (bool, error) {
err = waiter.WaitAtMost(func() (bool, error) {
_, err := client.LimitRanges(limitRangeNamespace).Get(limitRangeName, metav1.GetOptions{})
if err == nil {
return true, nil
}
return false, err
}, time.Minute)
require.NoError(t, err)

t.Log("Querying for Limit Ranges...")
var res limitRangeQueryResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type resourceQuotaStatus struct {
}

func TestResourceQuotaQuery(t *testing.T) {
dex.SkipTestIfShould(t)
dex.SkipTestIfSCIEnabled(t)

c, err := graphql.New()
require.NoError(t, err)
Expand All @@ -63,13 +63,14 @@ func TestResourceQuotaQuery(t *testing.T) {
_, err = k8sClient.ResourceQuotas(resourceQuotaNamespace).Create(fixResourceQuota())
require.NoError(t, err)

waiter.WaitAtMost(func() (bool, error) {
err = waiter.WaitAtMost(func() (bool, error) {
_, err := k8sClient.ResourceQuotas(resourceQuotaNamespace).Get(resourceQuotaName, metav1.GetOptions{})
if err == nil {
return true, nil
}
return false, err
}, time.Minute)
require.NoError(t, err)

var listResult resourceQuotas
var statusResult resourceQuotaStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,19 @@ import (
"fmt"
"testing"

"github.com/kyma-project/kyma/tests/ui-api-layer-acceptance-tests/internal/domain/shared"

"github.com/kyma-project/kyma/tests/ui-api-layer-acceptance-tests/internal/graphql"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

type ClusterServicePlan struct {
Name string
DisplayName string
ExternalName string
Description string
RelatedClusterServiceClassName string
InstanceCreateParameterSchema map[string]interface{}
}

type ClusterServiceClass struct {
Name string
ExternalName string
DisplayName string
CreationTimestamp int
Description string
LongDescription string
ImageUrl string
DocumentationUrl string
SupportUrl string
ProviderDisplayName string
Tags []string
Activated bool
Plans []ClusterServicePlan
apiSpec map[string]interface{}
asyncApiSpec map[string]interface{}
content map[string]interface{}
}

type clusterServiceClassesQueryResponse struct {
ClusterServiceClasses []ClusterServiceClass
ClusterServiceClasses []shared.ClusterServiceClass
}

type clusterServiceClassQueryResponse struct {
ClusterServiceClass ClusterServiceClass
ClusterServiceClass shared.ClusterServiceClass
}

func TestClusterServiceClassesQueries(t *testing.T) {
Expand Down Expand Up @@ -111,7 +85,7 @@ func TestClusterServiceClassesQueries(t *testing.T) {
})
}

func checkClusterClass(t *testing.T, expected, actual ClusterServiceClass) {
func checkClusterClass(t *testing.T, expected, actual shared.ClusterServiceClass) {
// Name
assert.Equal(t, expected.Name, actual.Name)

Expand All @@ -123,7 +97,7 @@ func checkClusterClass(t *testing.T, expected, actual ClusterServiceClass) {
assertClusterPlanExistsAndEqual(t, actual.Plans, expected.Plans[0])
}

func checkClusterPlan(t *testing.T, expected, actual ClusterServicePlan) {
func checkClusterPlan(t *testing.T, expected, actual shared.ClusterServicePlan) {
// Name
assert.Equal(t, expected.Name, actual.Name)

Expand All @@ -134,7 +108,7 @@ func checkClusterPlan(t *testing.T, expected, actual ClusterServicePlan) {
assert.Equal(t, expected.RelatedClusterServiceClassName, actual.RelatedClusterServiceClassName)
}

func assertClusterClassExistsAndEqual(t *testing.T, arr []ClusterServiceClass, expectedElement ClusterServiceClass) {
func assertClusterClassExistsAndEqual(t *testing.T, arr []shared.ClusterServiceClass, expectedElement shared.ClusterServiceClass) {
assert.Condition(t, func() (success bool) {
for _, v := range arr {
if v.Name == expectedElement.Name {
Expand All @@ -147,7 +121,7 @@ func assertClusterClassExistsAndEqual(t *testing.T, arr []ClusterServiceClass, e
}, "Resource does not exist")
}

func assertClusterPlanExistsAndEqual(t *testing.T, arr []ClusterServicePlan, expectedElement ClusterServicePlan) {
func assertClusterPlanExistsAndEqual(t *testing.T, arr []shared.ClusterServicePlan, expectedElement shared.ClusterServicePlan) {
assert.Condition(t, func() (success bool) {
for _, v := range arr {
if v.Name == expectedElement.Name {
Expand All @@ -160,12 +134,12 @@ func assertClusterPlanExistsAndEqual(t *testing.T, arr []ClusterServicePlan, exp
}, "Resource does not exist")
}

func clusterServiceClass() ClusterServiceClass {
return ClusterServiceClass{
func clusterServiceClass() shared.ClusterServiceClass {
return shared.ClusterServiceClass{
Name: "4f6e6cf6-ffdd-425f-a2c7-3c9258ad2468",
ExternalName: "user-provided-service",
Activated: false,
Plans: []ClusterServicePlan{
Plans: []shared.ClusterServicePlan{
{
Name: "86064792-7ea2-467b-af93-ac9694d96d52",
ExternalName: "default",
Expand Down
Loading