blob: 20efb281300eeab57815c02ff1a9b4a12b96bd2c (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/documentapi/loadtypes/loadtypeset.h>
#include <vespa/config/config.h>
#include <vespa/config/common/exceptions.h>
#include <vespa/vespalib/gtest/gtest.h>
#include <gmock/gmock.h>
using namespace ::testing;
namespace documentapi {
void
assertConfigFailure(const vespalib::string &configId, const vespalib::string &expError)
{
try {
LoadTypeSet createdFromConfigId(configId);
FAIL() << "Config was expected to fail with error: " << expError;
} catch (config::InvalidConfigException &e) {
EXPECT_THAT(e.getMessage(), HasSubstr(expError));
}
}
TEST(LoadTypeTest, testConfig)
{
// Using id 0 is illegal. Reserved for default type.
assertConfigFailure(
"raw:"
"type[1]\n"
"type[0].id 0\n"
"type[0].name \"foo\"\n"
"type[0].priority \"\"",
"Load type identifiers need to be");
// Using name "default" is illegal. Reserved for default type.
assertConfigFailure(
"raw:"
"type[1]\n"
"type[0].id 1\n"
"type[0].name \"default\"\n"
"type[0].priority \"\"", "Load type names need to be");
// Identifiers need to be unique.
assertConfigFailure(
"raw:"
"type[2]\n"
"type[0].id 1\n"
"type[0].name \"test\"\n"
"type[0].priority \"\"\n"
"type[1].id 1\n"
"type[1].name \"testa\"\n"
"type[1].priority \"\"", "Load type identifiers need to be");
// Names need to be unique.
assertConfigFailure(
"raw:"
"type[2]\n"
"type[0].id 1\n"
"type[0].name \"test\"\n"
"type[0].priority \"\"\n"
"type[1].id 2\n"
"type[1].name \"test\"\n"
"type[1].priority \"\"" , "Load type names need to be");
LoadTypeSet set("raw:"
"type[3]\n"
"type[0].id 1\n"
"type[0].name \"user\"\n"
"type[0].priority \"\"\n"
"type[1].id 2\n"
"type[1].name \"maintenance\"\n"
"type[1].priority \"\"\n"
"type[2].id 3\n"
"type[2].name \"put\"\n"
"type[2].priority \"\""
);
}
} // documentapi
GTEST_MAIN_RUN_ALL_TESTS()
|