Skip to content

Commit 2babf52

Browse files
Fix deserialize in tests (#536)
* Fewer dimensions for overrides tests * don't build java * optionally build java * Split fixtures * logging * Fix deserialize
1 parent 77aabe7 commit 2babf52

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/Integration/SqlTriggerBindingIntegrationTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,19 @@ void MonitorOutputData(object sender, DataReceivedEventArgs e)
578578
if (e.Data != null && (index = e.Data.IndexOf(messagePrefix, StringComparison.Ordinal)) >= 0)
579579
{
580580
string json = e.Data[(index + messagePrefix.Length)..];
581-
IReadOnlyList<SqlChange<Product>> changes = JsonConvert.DeserializeObject<IReadOnlyList<SqlChange<Product>>>(json);
581+
// Sometimes we'll get messages that have extra logging content on the same line - so to prevent that from breaking
582+
// the deserialization we look for the end of the changes array and only use that.
583+
// (This is fine since we control what content is in the array so know that none of the items have a ] in them)
584+
json = json[..(json.IndexOf(']') + 1)];
585+
IReadOnlyList<SqlChange<Product>> changes;
586+
try
587+
{
588+
changes = JsonConvert.DeserializeObject<IReadOnlyList<SqlChange<Product>>>(json);
589+
}
590+
catch (Exception ex)
591+
{
592+
throw new InvalidOperationException($"Exception deserializing JSON content. Error={ex.Message} Json=\"{json}\"", ex);
593+
}
582594
foreach (SqlChange<Product> change in changes)
583595
{
584596
Assert.Equal(operation, change.Operation); // Expected change operation

0 commit comments

Comments
 (0)