14
14
// limitations under the License.
15
15
//
16
16
17
+ import Logging
17
18
import SwiftkubeClient
18
19
import SwiftkubeModel
19
20
import XCTest
@@ -86,7 +87,7 @@ final class K3dConfigMapTests: K3dTestCase {
86
87
87
88
func testWatch( ) {
88
89
let expectedRecords = expectation ( description: " Expected Records " )
89
- let watcher = Watcher ( excpectation : expectedRecords, expectedCount: 5 )
90
+ let watcher = Watcher ( logger : K3dConfigMapTests . logger , expectation : expectedRecords, expectedCount: 5 )
90
91
91
92
let task = try ? K3dTestCase . client. configMaps. watch ( in: . namespace( " cm3 " ) , delegate: watcher)
92
93
@@ -95,7 +96,7 @@ final class K3dConfigMapTests: K3dTestCase {
95
96
_ = try ? K3dTestCase . client. configMaps. delete ( inNamespace: . namespace( " cm3 " ) , name: " test1 " ) . wait ( )
96
97
_ = try ? K3dTestCase . client. configMaps. update ( inNamespace: . namespace( " cm3 " ) , buildConfigMap ( " test2 " , data: [ " foo " : " bar " ] ) ) . wait ( )
97
98
98
- wait ( for: [ watcher. excpectedRecords ] , timeout: 5 )
99
+ wait ( for: [ watcher. expectedRecords ] , timeout: 30 )
99
100
task? . cancel ( )
100
101
101
102
assertEqual ( watcher. records, [
@@ -121,24 +122,26 @@ final class K3dConfigMapTests: K3dTestCase {
121
122
let resource : String
122
123
}
123
124
124
- let excpectedRecords : XCTestExpectation
125
+ let logger : Logger
126
+ let expectedRecords : XCTestExpectation
125
127
var expectedCount : Int
126
128
var records : [ Record ] = [ ]
127
129
128
- init ( excpectation: XCTestExpectation , expectedCount: Int ) {
129
- self . excpectedRecords = excpectation
130
+ init ( logger: Logger , expectation: XCTestExpectation , expectedCount: Int ) {
131
+ self . logger = logger
132
+ self . expectedRecords = expectation
130
133
self . expectedCount = expectedCount
131
134
}
132
135
133
136
func onEvent( event: EventType , resource: core . v1 . ConfigMap ) {
134
137
records. append ( Record ( eventType: event, resource: resource. name!) )
135
138
if records. count == expectedCount {
136
- excpectedRecords . fulfill ( )
139
+ expectedRecords . fulfill ( )
137
140
}
138
141
}
139
142
140
143
func onError( error: SwiftkubeClientError ) {
141
- // NOOP
144
+ logger . warning ( " Error encountered: \( error ) " )
142
145
}
143
146
}
144
147
}
0 commit comments