summaryrefslogtreecommitdiff
path: root/test/elixir/test/changes_test.exs
blob: b5545087b24ebf66d0fcc40f8cfe97a65888f7a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
defmodule ChangesTest do
  use CouchTestCase

  @moduletag :changes

  @moduledoc """
  Test CouchDB /{db}/_changes
  """

  @tag :with_db
  test "Changes feed negative heartbeat", context do
    db_name = context[:db_name]

    resp = Couch.get(
      "/#{db_name}/_changes",
      query: %{
        :feed => "continuous",
        :heartbeat => -1000
      }
    )

    assert resp.status_code == 400
    assert resp.body["error"] == "bad_request"
    assert resp.body["reason"] == "The heartbeat value should be a positive integer (in milliseconds)."
  end

  @tag :with_db
  test "Changes feed non-integer heartbeat", context do
    db_name = context[:db_name]

    resp = Couch.get(
      "/#{db_name}/_changes",
      query: %{
        :feed => "continuous",
        :heartbeat => "a1000"
      }
    )

    assert resp.status_code == 400
    assert resp.body["error"] == "bad_request"
    assert resp.body["reason"] == "Invalid heartbeat value. Expecting a positive integer value (in milliseconds)."
  end
end