forked from kubernetes-sigs/application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application_types_test.go
83 lines (64 loc) · 2.52 KB
/
application_types_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
72
73
74
75
76
77
78
79
80
81
82
83
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
. "github.com/kubernetes-sigs/application/pkg/apis/app/v1alpha1"
. "github.com/kubernetes-sigs/application/pkg/client/clientset/versioned/typed/app/v1alpha1"
)
// EDIT THIS FILE!
// Created by "kubebuilder create resource" for you to implement the Application resource tests
var _ = Describe("Application", func() {
var instance Application
var expected Application
var client ApplicationInterface
BeforeEach(func() {
instance = Application{}
instance.Name = "instance-1"
expected = instance
})
AfterEach(func() {
client.Delete(instance.Name, &metav1.DeleteOptions{})
})
// INSERT YOUR CODE HERE - add more "Describe" tests
// Automatically created storage tests
Describe("when sending a storage request", func() {
Context("for a valid config", func() {
It("should provide CRUD access to the object", func() {
client = cs.AppV1alpha1().Applications("default")
By("returning success from the create request")
actual, err := client.Create(&instance)
Expect(err).ShouldNot(HaveOccurred())
By("defaulting the expected fields")
Expect(actual.Spec).To(Equal(expected.Spec))
By("returning the item for list requests")
result, err := client.List(metav1.ListOptions{})
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Items).To(HaveLen(1))
Expect(result.Items[0].Spec).To(Equal(expected.Spec))
By("returning the item for get requests")
actual, err = client.Get(instance.Name, metav1.GetOptions{})
Expect(err).ShouldNot(HaveOccurred())
Expect(actual.Spec).To(Equal(expected.Spec))
By("deleting the item for delete requests")
err = client.Delete(instance.Name, &metav1.DeleteOptions{})
Expect(err).ShouldNot(HaveOccurred())
result, err = client.List(metav1.ListOptions{})
Expect(err).ShouldNot(HaveOccurred())
Expect(result.Items).To(HaveLen(0))
})
})
})
})