Skip to content

Commit 2f39644

Browse files
committed
Add _validate.tpl tests
1 parent e936842 commit 2f39644

File tree

3 files changed

+63
-6
lines changed

3 files changed

+63
-6
lines changed

helm/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@ For example, for the `security` checks, include and update these methods in the
5151

5252
```
5353
{{- define "fluss.validateWarning" -}}
54-
{{- include "fluss.security.validateWarning" . -}}
54+
...
55+
56+
{{- $messages = append $messages (include "fluss.security.validateWarning" .) -}}
57+
58+
...
5559
{{- end -}}
5660
5761
{{- define "fluss.validateError" -}}
58-
{{- include "fluss.security.validateError" . -}}
62+
...
63+
64+
{{- $messages = append $messages (include "fluss.security.validateError" .) -}}
65+
66+
...
5967
{{- end -}}
6068
```
6169

helm/templates/_validate.tpl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ Usage:
2222
include "fluss.validateWarning" .
2323
*/}}
2424
{{- define "fluss.validateWarning" -}}
25-
{{- include "fluss.security.validateWarning" . -}}
25+
{{- $messages := list -}}
26+
27+
{{- $messages = append $messages (include "fluss.security.validateWarning" .) -}}
28+
29+
{{- $messages = without $messages "" -}}
30+
{{- join "\n" $messages -}}
2631
{{- end -}}
2732

2833
{{/*
@@ -31,7 +36,12 @@ Usage:
3136
include "fluss.validateError" .
3237
*/}}
3338
{{- define "fluss.validateError" -}}
34-
{{- include "fluss.security.validateError" . -}}
39+
{{- $messages := list -}}
40+
41+
{{- $messages = append $messages (include "fluss.security.validateError" .) -}}
42+
43+
{{- $messages = without $messages "" -}}
44+
{{- join "\n" $messages -}}
3545
{{- end -}}
3646

3747
{{/*
@@ -44,13 +54,11 @@ Usage:
4454

4555
{{- $warnMessages := list -}}
4656
{{- $warnMessages = append $warnMessages (include "fluss.validateWarning" .) -}}
47-
4857
{{- $warnMessages = without $warnMessages "" -}}
4958
{{- $warnMessage := join "\n" $warnMessages -}}
5059

5160
{{- $errMessages := list -}}
5261
{{- $errMessages = append $errMessages (include "fluss.validateError" .) -}}
53-
5462
{{- $errMessages = without $errMessages "" -}}
5563
{{- $errMessage := join "\n" $errMessages -}}
5664

helm/tests/validate_test.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
suite: validate-aggregation
20+
templates:
21+
- templates/NOTES.txt
22+
tests:
23+
- it: renders warning for auto-generated internal SASL credentials
24+
set:
25+
security.internal.sasl.mechanism: plain
26+
asserts:
27+
- matchRegexRaw:
28+
pattern: 'VALUES WARNING:'
29+
- matchRegexRaw:
30+
pattern: 'AUTO-GENERATED SASL credentials'
31+
32+
- it: fails with error for invalid mechanism through aggregator
33+
set:
34+
security.client.sasl.mechanism: bogus
35+
asserts:
36+
- failedTemplate:
37+
errorMessage: "VALUES VALIDATION:\nsecurity.client.sasl.mechanism must be empty or: plain"
38+
39+
- it: passes cleanly with default values
40+
asserts:
41+
- notFailedTemplate: {}

0 commit comments

Comments
 (0)