File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed
tests/KubeOps.TestOperator.Test Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 13
13
14
14
namespace KubeOps . Testing
15
15
{
16
- public class KubernetesTestOperator : KubernetesOperator
16
+ public class KubernetesTestOperator : KubernetesOperator , IDisposable
17
17
{
18
18
public KubernetesTestOperator ( OperatorSettings settings )
19
19
: base ( settings )
@@ -37,6 +37,15 @@ public override Task<int> Run(string[] args)
37
37
return Task . FromResult ( 0 ) ;
38
38
}
39
39
40
+ public async void Dispose ( )
41
+ {
42
+ if ( OperatorHost != null )
43
+ {
44
+ await OperatorHost . StopAsync ( ) ;
45
+ }
46
+ OperatorHost ? . Dispose ( ) ;
47
+ }
48
+
40
49
protected override void ConfigureOperatorServices ( )
41
50
{
42
51
ConfigureServices (
Original file line number Diff line number Diff line change 1
- using System . Threading . Tasks ;
1
+ using System ;
2
+ using System . Threading . Tasks ;
2
3
using KubeOps . Testing ;
3
4
using KubeOps . TestOperator . Entities ;
4
5
using KubeOps . TestOperator . TestManager ;
9
10
10
11
namespace KubeOps . TestOperator . Test
11
12
{
12
- public class TestControllerTest
13
+ public class TestControllerTest : IDisposable
13
14
{
14
15
private readonly Mock < IManager > _mock = new Mock < IManager > ( ) ;
15
16
@@ -82,5 +83,10 @@ public async Task Test_If_Manager_StatusModified_Is_Called()
82
83
queue . StatusUpdated ( new TestEntity ( ) ) ;
83
84
_mock . Verify ( o => o . StatusModified ( It . IsAny < TestEntity > ( ) ) , Times . Once ) ;
84
85
}
86
+
87
+ public void Dispose ( )
88
+ {
89
+ _operator . Dispose ( ) ;
90
+ }
85
91
}
86
92
}
Original file line number Diff line number Diff line change 1
- using System . Threading . Tasks ;
1
+ using System ;
2
+ using System . Threading . Tasks ;
2
3
using k8s . Models ;
3
4
using KubeOps . Testing ;
4
5
using KubeOps . TestOperator . Entities ;
11
12
12
13
namespace KubeOps . TestOperator . Test
13
14
{
14
- public class TestFinalizerTest
15
+ public class TestFinalizerTest : IDisposable
15
16
{
16
17
private readonly Mock < IManager > _mock = new Mock < IManager > ( ) ;
17
18
@@ -47,5 +48,10 @@ public async Task Test_If_Manager_Finalized_Is_Called()
47
48
} ) ;
48
49
_mock . Verify ( o => o . Finalized ( It . IsAny < TestEntity > ( ) ) , Times . Once ) ;
49
50
}
51
+
52
+ public void Dispose ( )
53
+ {
54
+ _operator . Dispose ( ) ;
55
+ }
50
56
}
51
57
}
You can’t perform that action at this time.
0 commit comments