Skip to content

Commit 766d9d1

Browse files
stevejgordongithub-actions[bot]
authored andcommitted
Fix bug in AutoExpandReplicas.Create (#5260)
The create method was not allowing the valid value of "false. Fixes #5258
1 parent f1fd5d9 commit 766d9d1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Nest/IndexModules/IndexSettings/Settings/AutoExpandReplicas.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ public static AutoExpandReplicas Create(string value)
9898
if (value.IsNullOrEmpty())
9999
throw new ArgumentException("cannot be null or empty", nameof(value));
100100

101+
if (value.Equals("false", StringComparison.OrdinalIgnoreCase))
102+
return Disabled;
103+
101104
var expandReplicaParts = value.Split('-');
102105
if (expandReplicaParts.Length != 2)
103106
throw new ArgumentException("must contain a 'from' and 'to' value", nameof(value));

tests/Tests/CommonOptions/AutoExpandReplicas/AutoExpandReplicasTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ public void CreateWithMinAndAll()
7777
autoExpandReplicas.ToString().Should().Be("0-all");
7878
}
7979

80+
[U]
81+
public void CreateWithFalse()
82+
{
83+
var autoExpandReplicas = Nest.AutoExpandReplicas.Create("false");
84+
autoExpandReplicas.Should().NotBeNull();
85+
autoExpandReplicas.Enabled.Should().BeFalse();
86+
autoExpandReplicas.MinReplicas.Should().BeNull();
87+
autoExpandReplicas.MaxReplicas.Should().BeNull();
88+
autoExpandReplicas.ToString().Should().Be("false");
89+
}
90+
8091
[U]
8192
public void Disabled()
8293
{

0 commit comments

Comments
 (0)