Sha256: 68bed73be49a71b67f2e5dd869c12eb69defef9968c488f702b37bb191d65766

Contents?: true

Size: 1.61 KB

Versions: 16

Compression:

Stored size: 1.61 KB

Contents

#include <catch.hpp>
#include <internal/facts/resolvers/zfs_resolver.hpp>
#include <facter/facts/collection.hpp>
#include <facter/facts/fact.hpp>
#include <facter/facts/scalar_value.hpp>
#include "../../collection_fixture.hpp"

using namespace std;
using namespace facter::facts;
using namespace facter::facts::resolvers;
using namespace facter::testing;

struct empty_zfs_resolver : zfs_resolver
{
 protected:
    virtual string zfs_command() override
    {
        return "";
    }

    virtual data collect_data(collection& facts) override
    {
        data result;
        return result;
    }
};

struct test_zfs_resolver : zfs_resolver
{
 protected:
    virtual string zfs_command() override
    {
        return "";
    }

    virtual data collect_data(collection& facts) override
    {
        data result;
        result.version = "1";
        result.versions = { "1", "2", "3" };
        return result;
    }
};

SCENARIO("using the ZFS resolver") {
    collection_fixture facts;
    WHEN("data is not present") {
        facts.add(make_shared<empty_zfs_resolver>());
        THEN("facts should not be added") {
            REQUIRE(facts.size() == 0u);
        }
    }
    WHEN("data is present") {
        facts.add(make_shared<test_zfs_resolver>());
        THEN("flat facts are added") {
            REQUIRE(facts.size() == 2u);
            auto value = facts.get<string_value>(fact::zfs_version);
            REQUIRE(value);
            REQUIRE(value->value() == "1");
            value = facts.get<string_value>(fact::zfs_versionnumbers);
            REQUIRE(value);
            REQUIRE(value->value() == "1,2,3");
        }
    }
}

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/tests/facts/resolvers/zfs_resolver.cc