Skip to content

Commit

Permalink
Add annotation tests into test projects
Browse files Browse the repository at this point in the history
  • Loading branch information
fanzhangio committed Jun 1, 2018
1 parent 83156c1 commit 21160b9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
19 changes: 19 additions & 0 deletions test/projects/validations/pkg/apis/apps/v1/testkind_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ type TestKindSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "kubebuilder generate" to regenerate code after modifying this file
Count int `json:"count"`

// +kubebuilder:validation:Maximum=100
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:ExclusiveMinimum=true
Power float32 `json:"power,omitempty"`
Bricks int32 `json:"bricks,omitempty"`
// +kubebuilder:validation:MaxLength=15
// +kubebuilder:validation:MinLength=1
Name string `json:"name,omitempty"`
// +kubebuilder:validation:MaxItems=500
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:UniqueItems=false
Knights []string `json:"knights,omitempty"`
Winner bool `json:"winner,omitempty"`
// +kubebuilder:validation:Enum=Lion,Wolf,Dragon
Alias string `json:"alias,omitempty"`
// +kubebuilder:validation:Enum=1,2,3
Rank int `json:"rank"`
Comment []byte `json:"comment,omitempty"`
}

// TestKindStatus defines the observed state of TestKind
Expand Down
38 changes: 38 additions & 0 deletions test/projects/validations/test/hack/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,49 @@ spec:
type: object
spec:
properties:
alias:
enum:
- Lion
- Wolf
- Dragon
type: string
bricks:
format: int32
type: integer
comment:
format: byte
type: string
count:
format: int64
type: integer
knights:
items:
type: string
maxItems: 500
minItems: 1
type: array
name:
maxLength: 15
minLength: 1
type: string
power:
exclusiveMinimum: true
format: float
maximum: 100
minimum: 1
type: number
rank:
enum:
- 1
- 2
- 3
format: int64
type: integer
winner:
type: boolean
required:
- count
- rank
type: object
status:
type: object
Expand Down
8 changes: 6 additions & 2 deletions test_existing_projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

go test -v ./test/projects/memcached-api-server
go test -v ./test/projects/validations
for p in ./test/projects/*
do
if [[ -d "$p" ]]; then
go test -v "$p"
fi
done

0 comments on commit 21160b9

Please sign in to comment.