Sha256: 36772fb17113a64f4dacb912251c9d7f014149ef17811252ff0b3f93b856a6c9
Contents?: true
Size: 1.9 KB
Versions: 10
Compression:
Stored size: 1.9 KB
Contents
require 'test_helper' class DiscoveryAttributeSetTest < ActiveSupport::TestCase test "can search discovered hosts by cpu" do raw = parse_json_fixture('/facts.json') host = Host::Discovered.import_host_and_facts(raw['facts']).first results = Host::Discovered.search_for("cpu_count = #{host.facts_hash['physicalprocessorcount'].to_i}") assert_equal 1, results.count results = Host::Discovered.search_for("cpu_count > #{host.facts_hash['physicalprocessorcount'].to_i}") assert_equal 0, results.count end test "can search discovered hosts by memory" do raw = parse_json_fixture('/facts.json') host = Host::Discovered.import_host_and_facts(raw['facts']).first results = Host::Discovered.search_for("memory = #{host.facts_hash['memorysize_mb'].to_f.ceil}") assert_equal 1, results.count results = Host::Discovered.search_for("memory > #{host.facts_hash['memorysize_mb'].to_f.ceil}") assert_equal 0, results.count end test "can search discovered hosts by disk_count" do raw = parse_json_fixture('/facts.json') host = Host::Discovered.import_host_and_facts(raw['facts']).first results = Host::Discovered.search_for("disk_count = 1") assert_equal 1, results.count results = Host::Discovered.search_for("disk_count = 3") assert_equal 0, results.count end test "can search discovered hosts by disks_size" do raw = parse_json_fixture('/facts.json') host = Host::Discovered.import_host_and_facts(raw['facts']).first disks_size = (host.facts_hash['blockdevice_sda_size'].to_f / 1024 / 1024).ceil results = Host::Discovered.search_for("disks_size = #{disks_size}") assert_equal 1, results.count results = Host::Discovered.search_for("disks_size > #{disks_size}") assert_equal 0, results.count end def parse_json_fixture(relative_path) return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path))) end end
Version data entries
10 entries across 10 versions & 1 rubygems