Refine timestamp filter validation feedback
This commit is contained in:
parent
008e5a3f21
commit
25b1ee11ef
|
|
@ -218,16 +218,16 @@ public class WorkflowInstanceFilter
|
|||
if (timestampFilters == null)
|
||||
yield break;
|
||||
|
||||
foreach (var timestampFilter in timestampFilters)
|
||||
foreach (var (timestampFilter, index) in timestampFilters.Select((value, index) => (value, index)))
|
||||
{
|
||||
if (timestampFilter == null)
|
||||
{
|
||||
yield return "Timestamp filter must be specified.";
|
||||
yield return $"Timestamp filter at index {index} must be specified.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TryNormalizeTimestampFilterColumn(timestampFilter.Column, out _, out var error))
|
||||
yield return error;
|
||||
yield return $"Timestamp filter at index {index}: {error}";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ public class WorkflowInstanceFilter
|
|||
if (normalizedColumn != null)
|
||||
return true;
|
||||
|
||||
error = $"Invalid timestamp filter column '{column}'. Allowed columns are: {string.Join(", ", TimestampFilterColumns)}.";
|
||||
error = $"Invalid timestamp filter column. Allowed columns are: {string.Join(", ", TimestampFilterColumns)}.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class AlterationsApiTimestampFilterTests : IAsyncLifetime
|
|||
var body = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
Assert.Contains("Timestamp filter must be specified.", body);
|
||||
Assert.Contains("Timestamp filter at index 0 must be specified.", body);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -109,8 +109,8 @@ public class AlterationsApiTimestampFilterTests : IAsyncLifetime
|
|||
var body = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
Assert.Contains("Timestamp filter column must be specified.", body);
|
||||
Assert.Contains("Timestamp filter must be specified.", body);
|
||||
Assert.Contains("Timestamp filter at index 0: Timestamp filter column must be specified.", body);
|
||||
Assert.Contains("Timestamp filter at index 1 must be specified.", body);
|
||||
}
|
||||
|
||||
private static object CreateRequest(string path)
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
using Xunit;
|
||||
|
||||
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
||||
|
|
@ -67,7 +67,9 @@ public class WorkflowInstanceFilterTimestampTests
|
|||
var exception = Assert.Throws<ArgumentException>(() => filter.Apply(_workflowInstances).ToList());
|
||||
|
||||
Assert.Contains("Invalid timestamp filter column", exception.Message);
|
||||
Assert.Contains("CreatedAt, UpdatedAt, FinishedAt", exception.Message);
|
||||
Assert.DoesNotContain("CreatedAt == @0", exception.Message);
|
||||
foreach (var column in WorkflowInstanceFilter.AllowedTimestampFilterColumns)
|
||||
Assert.Contains(column, exception.Message);
|
||||
Assert.Equal($"{nameof(WorkflowInstanceFilter.TimestampFilters)}.Column", exception.ParamName);
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +101,7 @@ public class WorkflowInstanceFilterTimestampTests
|
|||
]).ToList();
|
||||
|
||||
var error = Assert.Single(errors);
|
||||
Assert.Equal("Timestamp filter column must be specified.", error);
|
||||
Assert.Equal("Timestamp filter at index 0: Timestamp filter column must be specified.", error);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -108,7 +110,7 @@ public class WorkflowInstanceFilterTimestampTests
|
|||
var errors = WorkflowInstanceFilter.ValidateTimestampFilters([null!]).ToList();
|
||||
|
||||
var error = Assert.Single(errors);
|
||||
Assert.Equal("Timestamp filter must be specified.", error);
|
||||
Assert.Equal("Timestamp filter at index 0 must be specified.", error);
|
||||
}
|
||||
|
||||
private DateTimeOffset GetMatchingTimestamp(string column) => column switch
|
||||
|
|
|
|||
Loading…
Reference in a new issue