---
"Help":
  - do:
      cat.aliases:
        help: true

  - match:
      $body: >
               /^  alias            .+   \n
                   index            .+   \n
                   filter           .+   \n
                   routing.index    .+   \n
                   routing.search   .+   \n
               $/

---
"Empty cluster":

  - do:
      cat.aliases: {}

  - match:
      $body: >
            /^
            $/

---
"Simple alias":

  - do:
        indices.create:
            index: test

  - do:
        indices.put_alias:
            index: test
            name:  test_alias

  - do:
      cat.aliases: {}

  - match:
      $body: >
                /^
                    test_alias          \s+
                    test                \s+
                    -                   \s+
                    -                   \s+
                    -                   \s+
                $/

---
"Complex alias":

  - do:
        indices.create:
            index: test

  - do:
        indices.put_alias:
            index: test
            name:  test_alias
            body:
                index_routing:  ir
                search_routing: "sr1,sr2"
                filter:
                    term:
                        foo: bar
  - do:
      cat.aliases: {}

  - match:
      $body: >
                /^
                    test_alias          \s+
                    test                \s+
                    [*]                 \s+
                    ir                  \s+
                    sr1,sr2             \s+
                $/

---
"Alias name":

  - do:
        indices.create:
            index: test

  - do:
        indices.put_alias:
            index: test
            name:  test_1

  - do:
        indices.put_alias:
            index: test
            name:  test_2

  - do:
      cat.aliases:
        name: test_1

  - match:
      $body: /^test_1 .+ \n$/

  - do:
      cat.aliases:
        name: test_2

  - match:
      $body: /^test_2 .+ \n$/

  - do:
      cat.aliases:
        name: test_*

  - match:
      $body: / (^|\n)test_1 .+ \n/

  - match:
      $body: / (^|\n)test_2 .+ \n/

---
"Column headers":

  - do:
        indices.create:
            index: test

  - do:
        indices.put_alias:
            index: test
            name:  test_1

  - do:
        cat.aliases:
            v: true

  - match:
      $body: >
               /^  alias           \s+
                   index           \s+
                   filter          \s+
                   routing.index   \s+
                   routing.search  \s+
                   \n
                   test_1          \s+
                   test            \s+
                   -               \s+
                   -               \s+
                   -               \s+
               $/


---
"Select columns":

  - do:
        indices.create:
            index: test

  - do:
        indices.put_alias:
            index: test
            name:  test_1

  - do:
        cat.aliases:
            h:      [index, alias]

  - match:
      $body: /^ test \s+ test_1 \s+ $/


  - do:
        cat.aliases:
            h:      [index, alias]
            v:      true
  - match:
      $body: >
            /^
                index \s+ alias  \s+ \n
                test  \s+ test_1 \s+ \n
            $/






