version: 2

models:
    - name: table_copy
      description: "A copy of the table"
      columns:
        - name: id
          description: "The ID"
          tests:
            - not_null
            - unique
          tags:
            - table_id
        - name: first_name
          description: "The user's first name"
          tests:
            - not_null
          tags:
            - table_first_name
        - name: ip_address
          description: "The user's IP address"
          tests:
            - not_null
        - name: updated_at
          description: "The update time of the user"
          tests:
            - not_null
        - name: email
          description: "The user's email address"
          tests:
            - unique
        - name: favorite_color
          description: "The user's favorite color"
          tests:
            - accepted_values: {
                values: ['blue', 'green'],
                quote: true,
                tags: table_copy_favorite_color  # tags can be a single string
            }
          tags:
            - table_favorite_color
        - name: fav_number
          description: "The user's favorite number"
          tests:
            - accepted_values:
                values: [3.14159265]
                quote: false
                tags:  # tags can be a list of strings
                  - favorite_number_is_pi


    - name: table_summary
      description: "The summary table"
      columns:
        - name: favorite_color_copy
          description: "The favorite color"
          tests:
            - not_null
            - unique
            - accepted_values: { values: ['blue', 'green'] }
            - relationships: { field: favorite_color, to: ref('table_copy') }
          tags:
            - table_favorite_color
        - name: count
          description: "The number of responses for this favorite color"
          tests:
            - not_null

# all of these constraints will fail
    - name: table_failure_copy
      description: "The table copy that does not comply with the schema"
      columns:
        - name: id
          description: "The user ID"
          tests:
            - not_null
            - unique
          tags:
            - xfail
        - name: favorite_color
          description: "The user's favorite color"
          tests:
            - accepted_values: { values: ['blue', 'green'] }
          tags:
            - xfail

# all of these constraints will fail
    - name: table_failure_summary
      description: "The table summary that does not comply with the schema"
      columns:
        - name: favorite_color
          description: "The favorite color"
          tests:
            - accepted_values: { values: ['red'] }
            - relationships: { field: favorite_color, to: ref('table_copy') }
          tags:
            - xfail

# this table is disabled so these tests should be ignored
    - name: table_disabled
      description: "A disabled table"
      columns:
        - name: favorite_color
          description: "The favorite color"
          tests:
            - accepted_values: { values: ['red'] }
            - relationships: { field: favorite_color, to: ref('table_copy') }

# all of these constraints will fail
    - name: table_failure_null_relation
      description: "A table with a null value where it should be a foreign key"
      columns:
        - name: id
          description: "The user ID"
          tests:
            - relationships: { field: id, to: ref('table_failure_copy') }
          tags:
            - xfail
