github.com/facebookincubator/ttpforge@v1.0.13-0.20240405153150-5ae801628835/example-ttps/tests/with-args.yaml (about) 1 --- 2 api_version: 2.0 3 uuid: ec37ddc7-37f6-4311-a05e-e7f00ae41504 4 name: Multiple Test Cases with Arguments 5 description: | 6 This TTP illustrates how to use the `tests` feature 7 to define multiple more complex test cases that rely on 8 command-line arguments. 9 tests: 10 - name: yes_cat_file 11 args: 12 target_file_base_path: /tmp/ttpforge_tests_example_yes_cat 13 # note the use of YAML block chomping via the '|-' 14 # so that our template renders correctly 15 # (see: https://yaml-multiline.info/) 16 contents: |- 17 this will be printed to the screen. 18 we deliberately chose a multiline string 19 to verify correct handling in arg string construction. 20 should_cat_file: true 21 - name: no_cat_file 22 args: 23 target_file_base_path: /tmp/ttpforge_tests_example_no_cat 24 contents: this will not be printed 25 args: 26 - name: target_file_base_path 27 type: path 28 description: | 29 The path of the file to create. 30 A random suffix will be added to allow the tests 31 to safely run in parallel. 32 - name: contents 33 description: the contents to write to the target file 34 - name: should_cat_file 35 type: bool 36 default: false 37 steps: 38 {{$target_file_path := (printf "%v_%v" .Args.target_file_base_path (randAlphaNum 10))}} 39 - name: create_a_file 40 create_file: {{ $target_file_path }} 41 contents: | 42 {{indent 6 .Args.contents}} 43 overwrite: true 44 cleanup: default 45 {{ if .Args.should_cat_file -}} 46 - name: cat_file 47 inline: cat {{$target_file_path}} 48 {{ end }}