blob: da35d10da52a2fd87c65fad946417a7a51951821 (
plain) (
blame)
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
38
39
40
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/config/common/configholder.h>
#include <vespa/config/common/sourcefactory.h>
#include <vespa/config/subscription/configsubscriber.hpp>
#include "config-my.h"
using namespace config;
TEST("require that raw spec can create source factory")
{
RawSpec spec("myField \"foo\"\n");
auto raw = spec.createSourceFactory(TimingValues());
ASSERT_TRUE(raw);
std::shared_ptr<IConfigHolder> holder(new ConfigHolder());
std::unique_ptr<Source> src = raw->createSource(holder, ConfigKey("myid", "my", "bar", "foo"));
ASSERT_TRUE(src);
src->getConfig();
ASSERT_TRUE(holder->poll());
std::unique_ptr<ConfigUpdate> update(holder->provide());
ASSERT_TRUE(update);
const ConfigValue & value(update->getValue());
ASSERT_EQUAL(1u, value.numLines());
ASSERT_EQUAL("myField \"foo\"", value.getLine(0));
}
TEST("requireThatRawSubscriptionReturnsCorrectConfig")
{
RawSpec spec("myField \"foo\"\n");
ConfigSubscriber s(spec);
std::unique_ptr<ConfigHandle<MyConfig> > handle = s.subscribe<MyConfig>("myid");
s.nextConfigNow();
std::unique_ptr<MyConfig> cfg = handle->getConfig();
ASSERT_TRUE(cfg);
ASSERT_EQUAL("foo", cfg->myField);
ASSERT_EQUAL("my", cfg->defName());
}
TEST_MAIN() { TEST_RUN_ALL(); }
|