summaryrefslogtreecommitdiff
path: root/test/integration/tmp_user_test.rb
blob: dff8f4e7c463e7b65955da91d19106a9f0d10526 (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
require_relative '../test_helper.rb'

class TmpUserTest < Tapicero::IntegrationTest

  def setup
    TapiceroProcess.run_with_config("test/config.yaml")
    create_user(false, 'tmp_users')
    sleep 0.1
  end

  def teardown
    delete_user(true, 'tmp_users')
  end

  def test_creates_user_db
    assert_database_exists user_database
  end

  def test_configures_security
    assert_equal config.options[:security], user_database.get('_security')
  end

  def test_stores_design_docs
    assert_equal ['_design/docs', '_design/syncs', '_design/transactions'],
      design_docs(user_database).map{|doc| doc["id"]}.sort
  end

  def test_deletes_user_db
    assert_database_exists user_database
    delete_user(false, 'tmp_users')
    assert !host.databases.include?(user_database.name), 'user db must not exist'
  end

  def design_docs(db)
    db.documents(startkey: '_design', endkey: '_design'.succ)["rows"]
  end
end