Source

htsql-charset-option / test / input / pgsql.yaml

Full commit
#
# Copyright (c) 2006-2010, Prometheus Research, LLC
# Authors: Clark C. Evans <cce@clarkevans.com>,
#          Kirill Simonov <xi@resolvent.net>
#

title: PostgreSQL regression tests
id: pgsql
output: test/output/pgsql.yaml
tests:
# FIXME: need a regression schema and a set of tests.

- title: Remove any existing regression database
  id: cleanup-pgsql
  tests:
  - connect: &admin-connect
      engine: pgsql
      database: postgres
      username: ${PGSQL_ADMIN_USERNAME}
      password: ${PGSQL_ADMIN_PASSWORD}
      host: ${PGSQL_HOST}
      port: ${PGSQL_PORT}
    sql: |
        DROP DATABASE IF EXISTS "htsql_regress";
        DROP ROLE IF EXISTS "htsql_regress";
    autocommit: true

- title: Deploy the regression database
  id: setup-pgsql
  tests:
  - connect: *admin-connect
    sql: |
        CREATE DATABASE "htsql_regress" WITH ENCODING = 'UTF-8';
        CREATE ROLE "htsql_regress" WITH LOGIN PASSWORD 'secret';
        ALTER DATABASE "htsql_regress" OWNER TO "htsql_regress";
    autocommit: true
  - connect: &connect
      engine: pgsql
      database: htsql_regress
      username: htsql_regress
      password: secret
      host: ${PGSQL_HOST}
      port: ${PGSQL_PORT}
    sql-include: test/sql/regress-pgsql.sql

- db: *connect

- title: Queries
  id: queries-pgsql
  tests:

  # Display all tables in the regression schema.
  - title: Regression schema
    tests:
    - uri: /school
    - uri: /department
    - uri: /program
    - uri: /course
    - uri: /instructor
    - uri: /confidential
    - uri: /appointment
    - uri: /semester
    - uri: /class
    - uri: /student
    - uri: /enrollment
    - uri: /prerequisite
    - uri: /classification
    - uri: /course_classification
    - uri: /program_requirement

  # Empty and scalar queries.
  - title: Scalar queries
    tests:
    - uri: /
    - uri: /{'HT'+'SQL'}

  # Simple (non-aggregate) filters.
  - title: Simple filters
    tests:
    - uri: /school?code='ns'
    - uri: /department?school.code='ns'
    - uri: /program?school.code='ns'&code='uchem'
    - uri: /course?credits=5

  # Simple (non-aggregate) selectors.
  - title: Simple selectors
    tests:
    - uri: /school{name}
    - uri: /department{school.*,*}
    - uri: /department{school.name+' - '+name}

  # Plural links and aggregates.
  - title: Aggregates
    tests:
    - uri: /department{code,count(course{credits=3})}
    - uri: /school{code,count(department.course{credits=3})}
    - uri: /school{code}?count(department.course{credits=3})=20
    - uri: /department?exists(course.credits=5)
    - uri: /department?every(course.credits=5)
    - uri: /department{code,min(course.credits),max(course.credits)}
    - uri: /department?exists(course)
    - uri: /school?!exists(department)
    - uri: /school{*,count(department)}
    - uri: /school{*,count(department?exists(course))}

  # Demonstrate selection of a formatter based on the `Accept` header.
  - title: Formatters
    tests:
    - uri: /school
      headers:
        Accept: application/json
    - uri: /school
      headers:
        Accept: text/csv
    - uri: /school
      headers:
        Accept: text/plain
    - uri: /school
      headers:
        Accept: text/html