diff options
Diffstat (limited to 'spec/frontend/editor/schema')
3 files changed, 70 insertions, 0 deletions
diff --git a/spec/frontend/editor/schema/ci/ci_schema_spec.js b/spec/frontend/editor/schema/ci/ci_schema_spec.js index 77c7f0d49a8..0f380f13679 100644 --- a/spec/frontend/editor/schema/ci/ci_schema_spec.js +++ b/spec/frontend/editor/schema/ci/ci_schema_spec.js @@ -36,6 +36,7 @@ import HooksYaml from './yaml_tests/positive_tests/hooks.yml'; import SecretsYaml from './yaml_tests/positive_tests/secrets.yml'; import ServicesYaml from './yaml_tests/positive_tests/services.yml'; import NeedsParallelMatrixYaml from './yaml_tests/positive_tests/needs_parallel_matrix.yml'; +import ScriptYaml from './yaml_tests/positive_tests/script.yml'; // YAML NEGATIVE TEST import ArtifactsNegativeYaml from './yaml_tests/negative_tests/artifacts.yml'; @@ -60,6 +61,7 @@ import ServicesNegativeYaml from './yaml_tests/negative_tests/services.yml'; import NeedsParallelMatrixNumericYaml from './yaml_tests/negative_tests/needs/parallel_matrix/numeric.yml'; import NeedsParallelMatrixWrongParallelValueYaml from './yaml_tests/negative_tests/needs/parallel_matrix/wrong_parallel_value.yml'; import NeedsParallelMatrixWrongMatrixValueYaml from './yaml_tests/negative_tests/needs/parallel_matrix/wrong_matrix_value.yml'; +import ScriptNegativeYaml from './yaml_tests/negative_tests/script.yml'; const ajv = new Ajv({ strictTypes: false, @@ -101,6 +103,7 @@ describe('positive tests', () => { ServicesYaml, SecretsYaml, NeedsParallelMatrixYaml, + ScriptYaml, }), )('schema validates %s', (_, input) => { // We construct a new "JSON" from each main key that is inside a @@ -144,6 +147,7 @@ describe('negative tests', () => { NeedsParallelMatrixNumericYaml, NeedsParallelMatrixWrongParallelValueYaml, NeedsParallelMatrixWrongMatrixValueYaml, + ScriptNegativeYaml, }), )('schema validates %s', (_, input) => { // We construct a new "JSON" from each main key that is inside a diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/script.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/script.yml new file mode 100644 index 00000000000..f5bf3f54f6f --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/script.yml @@ -0,0 +1,14 @@ +script: echo "invalid global script" + +default: + before_script: 0.1 + after_script: 1 + +invalid_script_type: + script: true + +empty_array_script: + script: [] + +empty_string_script: + script: "" diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/script.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/script.yml new file mode 100644 index 00000000000..0ffb1f3e89e --- /dev/null +++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/script.yml @@ -0,0 +1,52 @@ +default: + before_script: + - echo "default before_script" + after_script: | + echo "default after_script" + +valid_job_with_empty_string_script: + before_script: "" + after_script: "" + script: + - echo "overwrite default before_script and after_script" + +valid_job_with_empty_array_script: + before_script: [] + after_script: [] + script: + - echo "overwrite default before_script and after_script" + +valid_job_with_string_scripts: + before_script: echo before_script + script: echo script + after_script: echo after_script + +valid_job_with_multi_line_scripts: + before_script: | + echo multiline + echo before_script + script: | + echo multiline + echo script + after_script: | + echo multiline + echo after_script + +valid_job_with_array_scripts: + before_script: + - echo array + - echo before_script + script: + - echo array + - echo script + after_script: + - echo array + - echo after_script + +valid_job_with_nested_array_scripts: + before_script: + - [echo nested_array, echo before_script] + script: + - [echo nested_array, echo script] + after_script: + - [echo nested_array, echo after_script] |