Skip to content

Commit

Permalink
api tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory-Pereira committed Dec 3, 2021
1 parent 796ccfd commit fdc9be3
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 7 deletions.
44 changes: 39 additions & 5 deletions api/Onboard_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
package api

import "github.com/stretchr/testify/require"
import (
"github.com/stretchr/testify/require"
"os"
"github.com/operate-first/opfcli/constants"
"path/filepath"
)

func (suite *apiTestSuite) TestOnboard() {
func (suite *apiTestSuite) TestOnboardWithQuota() {
assert := require.New(suite.T())

err := suite.api.Onboard(
"./testdata/Onboard/sampleOnboardConfig.yaml",
err := os.MkdirAll(filepath.Join(
suite.api.RepoDirectory,
suite.api.AppName,
constants.ComponentPath,
"resourcequotas",
"testquota",
), 0755)
assert.Nil(err)

err = suite.api.Onboard(
"./testdata/Onboard/sampleOnboardConfigWithQuota.yaml",
"projectDisplayName",
false,
)
assert.Nil(err)
return

expectedPaths := []string{
"cluster-scope/base/core/namespaces/testproject/kustomization.yaml",
"cluster-scope/base/core/namespaces/testproject/namespace.yaml",
Expand All @@ -23,3 +37,23 @@ func (suite *apiTestSuite) TestOnboard() {
compareWithExpected(assert, "testdata/Onboard", suite.dir, expectedPaths)
}

// func (suite *apiTestSuite) TestOnboardWithoutQuota() {
// assert := require.New(suite.T())

// err := suite.api.Onboard(
// "./testdata/Onboard/sampleOnboardConfig.yaml",
// "projectDisplayName",
// false,
// )
// assert.Nil(err)

// expectedPaths := []string{
// "cluster-scope/base/core/namespaces/testproject/kustomizationWithoutQuota.yaml",
// "cluster-scope/base/core/namespaces/testproject/namespace.yaml",
// "cluster-scope/base/user.openshift.io/groups/testgroup/group.yaml",
// "cluster-scope/components/project-admin-rolebindings/testgroup/kustomization.yaml",
// "cluster-scope/components/project-admin-rolebindings/testgroup/rbac.yaml",
// }

// compareWithExpected(assert, "testdata/Onboard", suite.dir, expectedPaths)
// }
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: testproject
annotations:
openshift.io/requester: testgroup
openshift.io/display-name: test display name
openshift.io/display-name: projectDisplayName
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: user.openshift.io/v1
kind: Group
metadata:
name: testgroup
users: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- group.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: namespace-admin-testgroup
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: admin
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: testgroup
12 changes: 12 additions & 0 deletions api/testdata/Onboard/sampleOnboardConfigWithQuota.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
env: Smaug
namespaces:
- enable_monitoring: false
name: testproject
quota: testquota
project_description: This is the configuration for a sample project / app to onboard
target_cluster: Smaug
team_name: testgroup
template:
users:
- [email protected]
- [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ env: Smaug
namespaces:
- enable_monitoring: false
name: testproject
quota:
quota:
project_description: This is the configuration for a sample project / app to onboard
target_cluster: Smaug
team_name: testgroup
Expand Down

0 comments on commit fdc9be3

Please sign in to comment.