fix: Set CF IDs when no cache entry is present

Fixes #160
pull/201/head
Robert Dailey 1 year ago
parent 7ad4654d85
commit 28fa09f328

@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Remove unredacted request URI from log files on exception
- Remove unredacted request URI from log files on exception.
- Scores/Custom Formats would not sync under certain conditions (#160).
## [4.1.1] - 2023-01-06

@ -333,4 +333,27 @@ public class JsonTransactionStepTest
expectedTransactions.ConflictingCustomFormats.Add(new ConflictingCustomFormat(guideCfs[0], 1));
processor.Transactions.Should().BeEquivalentTo(expectedTransactions);
}
[Test, AutoMockData]
public void Service_cf_id_set_when_no_cache_entry(JsonTransactionStep processor)
{
const string serviceCfData = @"
[{
'id': 1,
'name': 'first'
}]";
var serviceCfs = JsonConvert.DeserializeObject<List<JObject>>(serviceCfData)!;
var guideCfs = new List<ProcessedCustomFormatData>
{
NewCf.Processed("first", "")
};
processor.Process(guideCfs, serviceCfs);
processor.Transactions.UpdatedCustomFormats.Should().BeEquivalentTo(
new[] {NewCf.Processed("first", "", new TrashIdMapping("", "first", 1))},
o => o.Including(x => x.CacheEntry!.CustomFormatId));
}
}

@ -51,7 +51,7 @@ public class JsonTransactionStep : IJsonTransactionStep
// Set the cache for use later (like updating scores) if it hasn't been updated already.
// This handles CFs that already exist in the service but aren't cached (they will be added to cache
// later).
guideCf.SetCache(guideCf.Json.Value<int>("id"));
guideCf.SetCache(serviceCf.Value<int>("id"));
}
guideCf.Json = (JObject) serviceCf.DeepClone();

Loading…
Cancel
Save