-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathTestHelpers.cs
More file actions
75 lines (72 loc) · 2.52 KB
/
TestHelpers.cs
File metadata and controls
75 lines (72 loc) · 2.52 KB
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
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
using System.Collections.Frozen;
using System.IO.Abstractions;
using Elastic.Documentation;
using Elastic.Documentation.Configuration;
using Elastic.Documentation.Configuration.LegacyUrlMappings;
using Elastic.Documentation.Configuration.Products;
using Elastic.Documentation.Configuration.Search;
using Elastic.Documentation.Configuration.Versions;
using Microsoft.Extensions.Logging.Abstractions;
namespace Elastic.Assembler.IntegrationTests;
public static class TestHelpers
{
public static IConfigurationContext CreateConfigurationContext(
IFileSystem fileSystem,
VersionsConfiguration? versionsConfiguration = null,
ConfigurationFileProvider? configurationFileProvider = null,
ProductsConfiguration? productsConfiguration = null
)
{
configurationFileProvider ??= new ConfigurationFileProvider(NullLoggerFactory.Instance, fileSystem, skipPrivateRepositories: true);
versionsConfiguration ??= new VersionsConfiguration
{
VersioningSystems = new Dictionary<VersioningSystemId, VersioningSystem>
{
{
VersioningSystemId.Stack, new VersioningSystem
{
Id = VersioningSystemId.Stack,
Current = new SemVersion(8, 0, 0),
Base = new SemVersion(8, 0, 0)
}
}
},
};
if (productsConfiguration is null)
{
var products = new Dictionary<string, Product>
{
{
"elasticsearch", new Product
{
Id = "elasticsearch",
DisplayName = "Elasticsearch",
VersioningSystem = versionsConfiguration.GetVersioningSystem(VersioningSystemId.Stack)
}
}
};
productsConfiguration = new ProductsConfiguration
{
Products = products.ToFrozenDictionary(),
PublicReferenceProducts = products.ToFrozenDictionary(),
ProductDisplayNames = products.ToDictionary(p => p.Key, p => p.Value.DisplayName).ToFrozenDictionary()
};
}
var search = new SearchConfiguration { Synonyms = new Dictionary<string, string[]>(), Rules = [], DiminishTerms = [] };
return new ConfigurationContext
{
Endpoints = new DocumentationEndpoints
{
Elasticsearch = ElasticsearchEndpoint.Default,
},
ConfigurationFileProvider = configurationFileProvider,
VersionsConfiguration = versionsConfiguration,
ProductsConfiguration = productsConfiguration,
SearchConfiguration = search,
LegacyUrlMappings = new LegacyUrlMappingConfiguration { Mappings = [] },
};
}
}