File tree Expand file tree Collapse file tree 4 files changed +28
-21
lines changed
Expand file tree Collapse file tree 4 files changed +28
-21
lines changed Original file line number Diff line number Diff line change @@ -10,16 +10,16 @@ public class AppendBlocksToPageTests : NotionTestsBase
1010{
1111 [ Theory ]
1212 [ MemberData ( nameof ( Blocks ) ) ]
13- public async Task AppendChildren_Succeds ( Block block )
13+ public async Task AppendChildren_Succeds ( Block block ) => await Retry ( async ( ) =>
1414 {
1515 var result = await SUT . AppendBlockChildrenAsync ( ValidPageId ,
16- new List < Block >
17- {
18- block
19- } ) ;
16+ new List < Block >
17+ {
18+ block
19+ } ) ;
2020 result . Should ( ) . NotBeNull ( ) ;
2121 await SUT . DeleteBlockAsync ( result . Results [ 0 ] . Id ) ;
22- }
22+ } , 3 ) ;
2323
2424 public static TheoryData < Block > Blocks { get ; } = new TheoryData < Block >
2525 {
Original file line number Diff line number Diff line change 1- using FluentAssertions ;
2-
3- using Notion . Model ;
4-
5- using Xunit ;
6-
7- namespace Notion . Sharp . Tests ;
1+ namespace Notion . Sharp . Tests ;
82
93public class ModelTests : NotionTestsBase
104{
Original file line number Diff line number Diff line change 11using Microsoft . Extensions . Configuration ;
22
3- using System ;
4-
53namespace Notion . Sharp . Tests ;
64
75public class NotionTestsBase
@@ -34,4 +32,22 @@ public NotionTestsBase()
3432 PageFromDatabase = Guid . Parse ( configuration [ "pageFromDatabase" ] ) ;
3533 SimpleDatabase = Guid . Parse ( configuration [ "simpleDatabase" ] ) ;
3634 }
35+
36+ public async Task Retry ( Func < Task > action , int attempts )
37+ {
38+ for ( var attempt = 0 ; attempt < attempts ; attempt ++ )
39+ {
40+ try
41+ {
42+ await action ( ) ;
43+ break ;
44+ }
45+ catch ( NotionException ex )
46+ {
47+ if ( ex . Message == "Conflict occurred while saving. Please try again." )
48+ continue ;
49+ throw ;
50+ }
51+ }
52+ }
3753}
Original file line number Diff line number Diff line change 1-
2- using Notion . Model ;
3-
4- namespace Notion . Sharp . Tests ;
1+ namespace Notion . Sharp . Tests ;
52
63public class RichTextsTests : NotionTestsBase
74{
@@ -22,7 +19,7 @@ public async Task GetRichText(string guid)
2219
2320 [ Theory ]
2421 [ MemberData ( nameof ( RichTexts ) ) ]
25- public async Task AppendRichText_Succed ( RichText richText )
22+ public async Task AppendRichText_Succed ( RichText richText ) => await Retry ( async ( ) =>
2623 {
2724 var result = await SUT . AppendBlockChildrenAsync ( ValidPageId , new List < Block >
2825 {
@@ -35,7 +32,7 @@ public async Task AppendRichText_Succed(RichText richText)
3532 }
3633 } ) ;
3734 var block = await SUT . DeleteBlockAsync ( result . Results [ 0 ] . Id ) ;
38- }
35+ } , 3 ) ;
3936
4037 public static TheoryData < RichText > RichTexts { get ; } = new TheoryData < RichText >
4138 {
You can’t perform that action at this time.
0 commit comments