Sha256: 7e23007d662fc183c41eb84b6e057bcd5af36f74c46e349c8b175db3e7fd0d6c

Contents?: true

Size: 1020 Bytes

Versions: 2

Compression:

Stored size: 1020 Bytes

Contents

require 't_helper'
require 'fidius-common/yamldb'
require 'sqlite3'
require 'fileutils'

require 'test_yamldb/db-install'
require 'test_yamldb/models/abc'
require 'test_yamldb/models/def'

BASE_DIR = File.join('test','test_yamldb')
MIGRATIONS = File.join(BASE_DIR, 'migrations')
DB_CONFIG = File.join(BASE_DIR, 'database.yml')
EXPORT_DIR = File.join(BASE_DIR, 'test_db')
TEST_DB = File.join(BASE_DIR, 'test_db.sqlite3')

include DbInstall

class YamlDbTest < Test::Unit::TestCase

  def setup
    DbInstall.migrate(MIGRATIONS, BASE_DIR)

    FIDIUS::Common::Db.export(DB_CONFIG, 'test_db', BASE_DIR, false)
  end

  def test_export
    assert(File.exists?(EXPORT_DIR))
    assert(File.exists?(File.join(EXPORT_DIR, 'test_db.yml')))
    assert(File.exists?(File.join(EXPORT_DIR, 'schema.rb')))
  end

  def test_import
    FIDIUS::Common::Db.import(DB_CONFIG, 'test_db', EXPORT_DIR)
  end

  def teardown
    FileUtils.rm_r EXPORT_DIR if File.exists? EXPORT_DIR
    FileUtils.rm TEST_DB if File.exists? TEST_DB
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fidius-common-0.0.6 test/test_yamldb.rb
fidius-common-0.0.5 test/test_yamldb.rb