spec/support/integration_helper.rb in rubix-0.4.0 vs spec/support/integration_helper.rb in rubix-0.4.1

- old
+ new

@@ -44,10 +44,18 @@ end end raise e end end + + def create_history item + (1..10).to_a.collect do |i| + history = { "itemid" => item.id.to_s, "clock" => (Time.now.to_i - 5*i).to_s, "value" => rand(100).to_s } + $RUBIX_MYSQL_CLIENT.query("INSERT INTO history_uint (#{history.keys.join(', ')}) VALUES (#{history.values.join(', ')})") + history + end + end def self.setup_integration_tests test_yml_path return unless File.exist?(test_yml_path) require 'yaml' @@ -66,18 +74,22 @@ truncate_all_tables $RUBIX_INTEGRATION_TEST = api_connection end - RUBIX_TABLES_TO_TRUNCATE = %w[applications groups hostmacro hosts hosts_groups hosts_profiles hosts_profiles_ext hosts_templates items items_applications profiles triggers trigger_depends] + RUBIX_TABLES_TO_TRUNCATE = %w[applications groups hostmacro hosts hosts_groups hosts_profiles hosts_profiles_ext hosts_templates items items_applications profiles triggers trigger_depends history sessions] def self.truncate_all_tables return unless $RUBIX_INTEGRATION_TEST RUBIX_TABLES_TO_TRUNCATE.each { |table| $RUBIX_MYSQL_CLIENT.query("TRUNCATE TABLE #{table}") } end def truncate_all_tables IntegrationHelper.truncate_all_tables + end + + def data_path *args + File.join(File.expand_path('../../data', __FILE__), *args) end end end