Skip to content

Commit 736bbfc

Browse files
committed
Try and reproduce #628 to no avail
1 parent 47cb51f commit 736bbfc

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Elasticsearch.Net;
5+
using Nest.Tests.MockData;
6+
using Nest.Tests.MockData.Domain;
7+
using NUnit.Framework;
8+
using System.Diagnostics;
9+
using FluentAssertions;
10+
11+
namespace Nest.Tests.Integration.Reproduce
12+
{
13+
[TestFixture]
14+
public class Reproduce628Tests : IntegrationTests
15+
{
16+
public class Post
17+
{
18+
public int Id { get; set; }
19+
public string Name { get; set; }
20+
}
21+
22+
23+
/// <summary>
24+
/// https://github.com/Mpdreamz/NEST/issues/682
25+
/// </summary>
26+
[Test]
27+
public void AliasesWithDashesAreNotStripped()
28+
{
29+
//unique indexaname already contains dasshes but lets be sure about this
30+
//if the implementation ever changes
31+
var index = ElasticsearchConfiguration.NewUniqueIndexName() + "-dashes";
32+
var x = this._client.CreateIndex(index);
33+
x.Acknowledged.Should().BeTrue();
34+
var alias = ElasticsearchConfiguration.NewUniqueIndexName() + "-dashed-alias";
35+
var aliasResult = this._client.Alias(a => a.Add(aa => aa.Index(index).Alias(alias)));
36+
aliasResult.IsValid.Should().BeTrue();
37+
aliasResult.Acknowledged.Should().BeTrue();
38+
39+
var getIndicesResult = _client.GetIndicesPointingToAlias(alias);
40+
getIndicesResult.Should().NotBeEmpty();
41+
42+
var indexReturned = getIndicesResult.First();
43+
indexReturned.Should().Be(index).And.Contain("-dashes");
44+
45+
46+
var getAliasesResult = this._client.GetAliasesPointingToIndex(index);
47+
getAliasesResult.Should().NotBeEmpty().And.HaveCount(1);
48+
49+
var aliasReturned = getAliasesResult.First().Name;
50+
aliasReturned.Should().Be(alias).And.Contain("-dashed-alias");
51+
52+
53+
var elasticsearchClient = new ElasticsearchClient(ElasticsearchConfiguration.Settings());
54+
var dynamicResult = elasticsearchClient.IndicesGetAlias(index);
55+
IDictionary<string, object> aliases = dynamicResult.Response[index].aliases;
56+
aliases.Count.Should().Be(1);
57+
var aliasDynamic = aliases.Keys.First();
58+
aliasDynamic.Should().Be(alias);
59+
60+
}
61+
62+
}
63+
}

0 commit comments

Comments
 (0)