11using Google . Protobuf . WellKnownTypes ;
2+ using Serval . Translation . Configuration ;
23using Serval . Translation . Models ;
34using Serval . Translation . V1 ;
45using SIL . ServiceToolkit . Services ;
@@ -2459,6 +2460,52 @@ await corporaClient.UpdateAsync(
24592460 Assert . That ( newEngine2 . ParallelCorpora [ 0 ] . TargetCorpora [ 0 ] . Files . Count , Is . EqualTo ( 1 ) ) ;
24602461 }
24612462
2463+ [ Test ]
2464+ public async Task MongoMigration_TargetQuoteConvention ( )
2465+ {
2466+ await _env . Builds . InsertAsync (
2467+ new Build ( )
2468+ {
2469+ Id = "111111111111111111111111" ,
2470+ EngineRef = NMT_ENGINE1_ID ,
2471+ Owner = "client1" ,
2472+ Analysis =
2473+ [
2474+ new Shared . Models . ParallelCorpusAnalysis ( )
2475+ {
2476+ ParallelCorpusRef = "111111111111111111111112" ,
2477+ TargetQuoteConvention = ""
2478+ } ,
2479+ new Shared . Models . ParallelCorpusAnalysis ( )
2480+ {
2481+ ParallelCorpusRef = "111111111111111111111113" ,
2482+ TargetQuoteConvention = "standard_english"
2483+ }
2484+ ]
2485+ }
2486+ ) ;
2487+
2488+ Build ? unmigratedBuild = await _env . Builds . GetAsync ( b => b . Id == "111111111111111111111111" ) ;
2489+ Assert . That ( unmigratedBuild , Is . Not . Null ) ;
2490+ Assert . Multiple ( ( ) =>
2491+ {
2492+ Assert . That ( unmigratedBuild . Analysis , Has . Count . EqualTo ( 2 ) ) ;
2493+ Assert . That ( unmigratedBuild . TargetQuoteConvention , Is . Null ) ;
2494+ } ) ;
2495+
2496+ await MongoMigrations . MigrateTargetQuoteConvention (
2497+ _env . MongoClient . GetDatabase ( "serval_test" ) . GetCollection < Build > ( "translation.builds" )
2498+ ) ;
2499+
2500+ Build ? migratedBuild = await _env . Builds . GetAsync ( b => b . Id == "111111111111111111111111" ) ;
2501+ Assert . That ( migratedBuild , Is . Not . Null ) ;
2502+ Assert . Multiple ( ( ) =>
2503+ {
2504+ Assert . That ( migratedBuild . Analysis , Has . Count . EqualTo ( 2 ) ) ;
2505+ Assert . That ( migratedBuild . TargetQuoteConvention , Is . EqualTo ( "standard_english" ) ) ;
2506+ } ) ;
2507+ }
2508+
24622509 [ TearDown ]
24632510 public void TearDown ( )
24642511 {
@@ -2468,11 +2515,11 @@ public void TearDown()
24682515 private class TestEnvironment : DisposableBase
24692516 {
24702517 private readonly IServiceScope _scope ;
2471- private readonly MongoClient _mongoClient ;
2518+ public readonly MongoClient MongoClient ;
24722519
24732520 public TestEnvironment ( )
24742521 {
2475- _mongoClient = new MongoClient ( ) ;
2522+ MongoClient = new MongoClient ( ) ;
24762523 ResetDatabases ( ) ;
24772524
24782525 Factory = new ServalWebApplicationFactory ( ) ;
@@ -2795,8 +2842,8 @@ public CorporaClient CreateCorporaClient()
27952842
27962843 public void ResetDatabases ( )
27972844 {
2798- _mongoClient . DropDatabase ( "serval_test" ) ;
2799- _mongoClient . DropDatabase ( "serval_test_jobs" ) ;
2845+ MongoClient . DropDatabase ( "serval_test" ) ;
2846+ MongoClient . DropDatabase ( "serval_test_jobs" ) ;
28002847 }
28012848
28022849 private static IFileSystem CreateFileSystem ( IServiceProvider sp )
0 commit comments