Skip to content

Commit

Permalink
Move test CRD into shared test directory
Browse files Browse the repository at this point in the history
[#169]

Co-authored-by: Emily Johnson <emjohnson@vmware.com>
  • Loading branch information
Rasheed Abdul-Aziz and emmjohnson committed Sep 29, 2021
1 parent b1379ee commit e30d825
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 35 deletions.
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ gen-manifests:
-f ./hack/boilerplate.go.txt \
config/crd/bases

tests/integration/pipeline_service/testapi/zz_generated.deepcopy.go: tests/integration/pipeline_service/testapi/*.go
tests/resources/zz_generated.deepcopy.go: tests/resources/*.go
go run sigs.k8s.io/controller-tools/cmd/controller-gen \
object \
paths=./tests/integration/pipeline_service/testapi
paths=./tests/resources

.PHONY: test-gen-objects
test-gen-objects: tests/integration/pipeline_service/testapi/zz_generated.deepcopy.go
test-gen-objects: tests/resources/zz_generated.deepcopy.go

tests/integration/pipeline_service/testapi/crds/*.yaml: tests/integration/pipeline_service/testapi/*.go
tests/resources/crds/*.yaml: tests/resources/*.go
go run sigs.k8s.io/controller-tools/cmd/controller-gen \
crd \
paths=./tests/integration/pipeline_service/testapi \
output:crd:artifacts:config=./tests/integration/pipeline_service/testapi/crds
paths=./tests/resources \
output:crd:artifacts:config=./tests/resources/crds
go run github.com/google/addlicense \
-f ./hack/boilerplate.go.txt \
./tests/integration/pipeline_service/testapi/crds
./tests/resources/crds

.PHONY: test-gen-manifests
test-gen-manifests: tests/integration/pipeline_service/testapi/crds/*.yaml
test-gen-manifests: tests/resources/crds/*.yaml

.PHONY: clean-fakes
clean-fakes:
Expand All @@ -51,7 +51,7 @@ generate: clean-fakes
go generate ./...

.PHONY: test-unit
test-unit:
test-unit: test-gen-objects
go run github.com/onsi/ginkgo/ginkgo -r pkg

.PHONY: test-integration
Expand Down Expand Up @@ -93,7 +93,6 @@ lint: copyright
go run github.com/golangci/golangci-lint/cmd/golangci-lint --config lint-config.yaml run
$(MAKE) -C hack lint


.PHONY: copyright
copyright:
go run github.com/google/addlicense \
Expand Down
2 changes: 1 addition & 1 deletion kuttl-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ testDirs:
- tests/kuttl
crdDir: config/crd/bases
manifestDirs:
- tests/integration/pipeline_service/testapi/crds
- tests/resources/crds
commands:
- command: build/cartographer
background: true
Expand Down
11 changes: 6 additions & 5 deletions pkg/realizer/pipeline/realizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
realizer "github.com/vmware-tanzu/cartographer/pkg/realizer/pipeline"
"github.com/vmware-tanzu/cartographer/pkg/repository/repositoryfakes"
"github.com/vmware-tanzu/cartographer/pkg/templates"
"github.com/vmware-tanzu/cartographer/tests/integration/pipeline_service/testapi"
"github.com/vmware-tanzu/cartographer/tests/resources"
)

var _ = Describe("Realizer", func() {
Expand Down Expand Up @@ -67,18 +67,18 @@ var _ = Describe("Realizer", func() {

Context("with a valid RunTemplate", func() {
BeforeEach(func() {
testObj := testapi.Test{
testObj := resources.Test{
TypeMeta: metav1.TypeMeta{
Kind: "Test",
APIVersion: "test.run/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
GenerateName: "my-stamped-resource-",
},
Spec: testapi.TestSpec{
Spec: resources.TestSpec{
Foo: "is a string",
},
Status: testapi.TestStatus{
Status: resources.TestStatus{
ObservedGeneration: 1,
Conditions: []metav1.Condition{{
Type: "Succeeded",
Expand Down Expand Up @@ -161,7 +161,8 @@ var _ = Describe("Realizer", func() {
It("returns the stampedObject", func() {
_, _, stampedObject := rlzr.Realize(context.TODO(), pipeline, logger, repository)
Expect(stampedObject.Object["spec"]).To(Equal(map[string]interface{}{
"foo": "is a string",
"foo": "is a string",
"value": nil,
}))
Expect(stampedObject.Object["apiVersion"]).To(Equal("test.run/v1alpha1"))
Expect(stampedObject.Object["kind"]).To(Equal("Test"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ import (

"github.com/vmware-tanzu/cartographer/pkg/apis/v1alpha1"
"github.com/vmware-tanzu/cartographer/pkg/root"
"github.com/vmware-tanzu/cartographer/tests/integration/pipeline_service/testapi"
"github.com/vmware-tanzu/cartographer/tests/resources"
)

func TestWebhookIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration Suite")
RunSpecs(t, "Pipeline Service Integration Suite")
}

var (
Expand Down Expand Up @@ -72,7 +72,7 @@ var _ = BeforeSuite(func() {
},
CRDDirectoryPaths: []string{
filepath.Join("..", "..", "..", "config", "crd", "bases"),
filepath.Join("testapi", "crds"),
filepath.Join("..", "..", "resources", "crds"),
},
AttachControlPlaneOutput: DebugControlPlane, // Set to true for great debug logging
}
Expand Down Expand Up @@ -127,7 +127,7 @@ var _ = BeforeSuite(func() {
err = corev1.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

err = testapi.AddToScheme(scheme)
err = resources.AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

c, err = client.New(apiConfig, client.Options{
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/pipeline_service/pipeline_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

"github.com/vmware-tanzu/cartographer/pkg/apis/v1alpha1"
. "github.com/vmware-tanzu/cartographer/pkg/utils"
"github.com/vmware-tanzu/cartographer/tests/integration/pipeline_service/testapi"
"github.com/vmware-tanzu/cartographer/tests/resources"
)

var _ = Describe("Stamping a resource on Pipeline Creation", func() {
Expand Down Expand Up @@ -332,9 +332,9 @@ var _ = Describe("Stamping a resource on Pipeline Creation", func() {
client.MatchingLabels(map[string]string{"carto.run/pipeline-name": "my-pipeline"}),
}

testsList := &testapi.TestList{}
testsList := &resources.TestList{}

Eventually(func() ([]testapi.Test, error) {
Eventually(func() ([]resources.Test, error) {
err := c.List(ctx, testsList, opts...)
return testsList.Items, err
}).Should(HaveLen(1))
Expand Down Expand Up @@ -477,9 +477,9 @@ var _ = Describe("Stamping a resource on Pipeline Creation", func() {
client.MatchingLabels(map[string]string{"carto.run/pipeline-name": "my-pipeline"}),
}

testsList := &testapi.TestList{}
testsList := &resources.TestList{}

Eventually(func() ([]testapi.Test, error) {
Eventually(func() ([]resources.Test, error) {
err := c.List(ctx, testsList, opts...)
return testsList.Items, err
}).Should(HaveLen(1))
Expand All @@ -492,7 +492,7 @@ var _ = Describe("Stamping a resource on Pipeline Creation", func() {
err = c.Update(ctx, runTemplateDefinition, &client.UpdateOptions{})
Expect(err).NotTo(HaveOccurred())

Eventually(func() ([]testapi.Test, error) {
Eventually(func() ([]resources.Test, error) {
err := c.List(ctx, testsList, opts...)
return testsList.Items, err
}).Should(HaveLen(2))
Expand All @@ -506,7 +506,7 @@ var _ = Describe("Stamping a resource on Pipeline Creation", func() {
err = c.Update(ctx, runTemplateDefinition, &client.UpdateOptions{})
Expect(err).NotTo(HaveOccurred())

Eventually(func() ([]testapi.Test, error) {
Eventually(func() ([]resources.Test, error) {
err := c.List(ctx, testsList, opts...)
return testsList.Items, err
}).Should(HaveLen(3))
Expand All @@ -527,9 +527,9 @@ var _ = Describe("Stamping a resource on Pipeline Creation", func() {
client.MatchingLabels(map[string]string{"gen": "2"}),
}

testsList := &testapi.TestList{}
testsList := &resources.TestList{}

Eventually(func() ([]testapi.Test, error) {
Eventually(func() ([]resources.Test, error) {
err := c.List(ctx, testsList, opts...)
return testsList.Items, err
}).Should(HaveLen(1))
Expand Down Expand Up @@ -563,7 +563,7 @@ var _ = Describe("Stamping a resource on Pipeline Creation", func() {
client.MatchingLabels(map[string]string{"gen": "1"}),
}

Eventually(func() ([]testapi.Test, error) {
Eventually(func() ([]resources.Test, error) {
err := c.List(ctx, testsList, opts...)
return testsList.Items, err
}).Should(HaveLen(1))
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/supply_chain/supply_chain_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (

func TestWebhookIntegration(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration Suite")
RunSpecs(t, "Supply Chain Integration Suite")
}

var (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package testapi
package resources

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// +groupName=test.run
// +kubebuilder:object:generate=true

package testapi
package resources

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -39,7 +39,7 @@ type TestStatus struct {
}

type TestSpec struct {
Foo string `json:"foo,omitempty"`
Foo string `json:"foo,omitempty"`
// +kubebuilder:pruning:PreserveUnknownFields
Value runtime.RawExtension `json:"value,omitempty"`
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e30d825

Please sign in to comment.