---
setup:

  - do:
      indices.create:
        index: test_index1

  - do:
      indices.create:
        index: test_index2

  - do:
      indices.create:
        index: foo

  - do:
      cluster.health:
        wait_for_status: yellow

---
"put warmer per index":

  - do:
      indices.put_warmer:
        index: test_index1
        name: warmer
        body:
          query:
            match_all: {}
  - do:
      indices.put_warmer:
        index: test_index2
        name: warmer
        body:
          query:
            match_all: {}

  - do:
      indices.get_warmer: { index: _all, name: '*' }

  - match: {test_index1.warmers.warmer.source.query.match_all: {}}
  - match: {test_index2.warmers.warmer.source.query.match_all: {}}
  - is_false: foo

---
"put warmer in _all index":
  - do:
      indices.put_warmer:
        index: _all
        name: warmer
        body:
          query:
            match_all: {}
  - do:
      indices.get_warmer: { index: _all, name: '*' }

  - match: {test_index1.warmers.warmer.source.query.match_all: {}}
  - match: {test_index2.warmers.warmer.source.query.match_all: {}}
  - match: {foo.warmers.warmer.source.query.match_all: {}}

---
"put warmer in * index":
  - do:
      indices.put_warmer:
        index: "*"
        name: warmer
        body:
          query:
            match_all: {}
  - do:
      indices.get_warmer: { index: _all, name: '*' }

  - match: {test_index1.warmers.warmer.source.query.match_all: {}}
  - match: {test_index2.warmers.warmer.source.query.match_all: {}}
  - match: {foo.warmers.warmer.source.query.match_all: {}}

---
"put warmer prefix* index":
  - do:
      indices.put_warmer:
        index: "test_index*"
        name: warmer
        body:
          query:
            match_all: {}
  - do:
      indices.get_warmer: { index: _all, name: '*' }

  - match: {test_index1.warmers.warmer.source.query.match_all: {}}
  - match: {test_index2.warmers.warmer.source.query.match_all: {}}
  - is_false: foo

---
"put warmer in list of indices":
  - do:
      indices.put_warmer:
        index: [test_index1, test_index2]
        name: warmer
        body:
          query:
            match_all: {}
  - do:
      indices.get_warmer: { index: _all, name: '*' }

  - match: {test_index1.warmers.warmer.source.query.match_all: {}}
  - match: {test_index2.warmers.warmer.source.query.match_all: {}}
  - is_false: foo

---
"put warmer with blank index":
  - do:
      indices.put_warmer:
        name: warmer
        body:
          query:
            match_all: {}
  - do:
      indices.get_warmer: { index: _all, name: '*' }

  - match: {test_index1.warmers.warmer.source.query.match_all: {}}
  - match: {test_index2.warmers.warmer.source.query.match_all: {}}
  - match: {foo.warmers.warmer.source.query.match_all: {}}

---
"put warmer with missing name":


  - do:
      catch: param
      indices.put_warmer:
        body:
          query:
            match_all: {}