Skip to content

Commit 065ad5b

Browse files
authored
Merge pull request #251 from fanzhangio/annotation-test
Add annotation tests into test projects
2 parents 83156c1 + 21160b9 commit 065ad5b

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

test/projects/validations/pkg/apis/apps/v1/testkind_types.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ type TestKindSpec struct {
1414
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
1515
// Important: Run "kubebuilder generate" to regenerate code after modifying this file
1616
Count int `json:"count"`
17+
18+
// +kubebuilder:validation:Maximum=100
19+
// +kubebuilder:validation:Minimum=1
20+
// +kubebuilder:validation:ExclusiveMinimum=true
21+
Power float32 `json:"power,omitempty"`
22+
Bricks int32 `json:"bricks,omitempty"`
23+
// +kubebuilder:validation:MaxLength=15
24+
// +kubebuilder:validation:MinLength=1
25+
Name string `json:"name,omitempty"`
26+
// +kubebuilder:validation:MaxItems=500
27+
// +kubebuilder:validation:MinItems=1
28+
// +kubebuilder:validation:UniqueItems=false
29+
Knights []string `json:"knights,omitempty"`
30+
Winner bool `json:"winner,omitempty"`
31+
// +kubebuilder:validation:Enum=Lion,Wolf,Dragon
32+
Alias string `json:"alias,omitempty"`
33+
// +kubebuilder:validation:Enum=1,2,3
34+
Rank int `json:"rank"`
35+
Comment []byte `json:"comment,omitempty"`
1736
}
1837

1938
// TestKindStatus defines the observed state of TestKind

test/projects/validations/test/hack/install.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,49 @@ spec:
2323
type: object
2424
spec:
2525
properties:
26+
alias:
27+
enum:
28+
- Lion
29+
- Wolf
30+
- Dragon
31+
type: string
32+
bricks:
33+
format: int32
34+
type: integer
35+
comment:
36+
format: byte
37+
type: string
2638
count:
2739
format: int64
2840
type: integer
41+
knights:
42+
items:
43+
type: string
44+
maxItems: 500
45+
minItems: 1
46+
type: array
47+
name:
48+
maxLength: 15
49+
minLength: 1
50+
type: string
51+
power:
52+
exclusiveMinimum: true
53+
format: float
54+
maximum: 100
55+
minimum: 1
56+
type: number
57+
rank:
58+
enum:
59+
- 1
60+
- 2
61+
- 3
62+
format: int64
63+
type: integer
64+
winner:
65+
type: boolean
2966
required:
3067
- count
68+
- rank
3169
type: object
3270
status:
3371
type: object

test_existing_projects.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
go test -v ./test/projects/memcached-api-server
18-
go test -v ./test/projects/validations
17+
for p in ./test/projects/*
18+
do
19+
if [[ -d "$p" ]]; then
20+
go test -v "$p"
21+
fi
22+
done

0 commit comments

Comments
 (0)