github.com/mmatczuk/gohan@v0.0.0-20170206152520-30e45d9bdb69/extension/gohanscript/lib/tests/gohan_test.yaml (about)

     1  test_suite:
     2    tests:
     3    - name: Config test
     4      test:
     5      - read_config: path="{{ __dir__ }}/config.yaml"
     6      - get_config: key=database/connection default_value=""
     7        register: connection
     8      - assert: expect="./test.db" actual="{{ connection }}"
     9    - name: CRUD DB test
    10      test:
    11      - command: rm ./test.db
    12        rescue: []
    13      - gohan_load_schema: src="{{ __dir__ }}/schema.yaml"
    14      - connect_db: db_type=sqlite3 connection=./test.db max_open_conn=1
    15        register: db
    16      - init_db:
    17          db_type: sqlite3
    18          connection: ./test.db
    19          drop_on_create: false
    20          cascade: false
    21      - transaction:
    22        - db_create:
    23            tx: $transaction
    24            schema_id: network
    25            data:
    26              id: test_network
    27              name: test
    28        - db_create:
    29            tx: $transaction
    30            schema_id: subnet
    31            data:
    32              id: test_subnet
    33              name: test
    34              network_id: test_network
    35        - db_list:
    36            schema_id: network
    37            tx: $transaction
    38            filter: {}
    39          register: list
    40        - assert: expect=1 actual="{{ list | length }}"
    41        - db_update:
    42            tx: $transaction
    43            schema_id: network
    44            id: test_network
    45            data:
    46              id: test_network
    47              name: test2
    48        - db_list:
    49            schema_id: network
    50            tx: $transaction
    51            filter: {}
    52          register: list
    53        - db_column:
    54            schema_id: network
    55            join: false
    56          register: network_columns
    57        - db_query:
    58            schema_id: network
    59            tx: $transaction
    60            sql: |
    61              select {{ network_columns }} from networks where
    62                exists(select id from subnets where network_id == networks.id)
    63                and networks.name == ?
    64            arguments:
    65            - test2
    66          register: query_result
    67        - assert: expect=test2 actual="{{ query_result.0.name }}"
    68        - assert: expect=test2 actual="{{ list.0.name }}"
    69        - db_delete:
    70            tx: $transaction
    71            schema_id: subnet
    72            id: test_subnet
    73        - db_delete:
    74            tx: $transaction
    75            schema_id: network
    76            id: test_network
    77        - db_list:
    78            tx: $transaction
    79            schema_id: network
    80            filter: {}
    81          register: list
    82        - assert: expect=0 actual="{{ list | length }}"
    83        connection: $db