Skip to content

Commit b887a0a

Browse files
author
Ignacio Bonafonte
authored
Merge pull request #305 from BlueOwlOpenSource/fixes-test-failure-when-fulfill-calls-multiple-times
2 parents 5e6a212 + 1c2e705 commit b887a0a

14 files changed

+29
-7
lines changed

Tests/ExportersTests/DatadogExporter/Files/FileTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import XCTest
88

99
class FileTests: XCTestCase {
1010
private let fileManager = FileManager.default
11+
private let temporaryDirectory = obtainUniqueTemporaryDirectory()
1112

1213
override func setUp() {
1314
super.setUp()

Tests/ExportersTests/DatadogExporter/Helpers/TestsDirectory.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func obtainUniqueTemporaryDirectory() -> Directory {
1818

1919
/// `Directory` pointing to subfolder in `/var/folders/`.
2020
/// The subfolder does not exist and can be created and deleted by calling `.create()` and `.delete()`.
21-
let temporaryDirectory = obtainUniqueTemporaryDirectory()
21+
//let temporaryDirectory = obtainUniqueTemporaryDirectory()
2222

2323
/// Extends `Directory` with set of utilities for convenient work with files in tests.
2424
/// Provides handy methods to create / delete files and directires.

Tests/ExportersTests/DatadogExporter/Persistence/FileReaderTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import XCTest
88

99
class FileReaderTests: XCTestCase {
10+
private let temporaryDirectory = obtainUniqueTemporaryDirectory()
11+
1012
override func setUp() {
1113
super.setUp()
1214
temporaryDirectory.create()

Tests/ExportersTests/DatadogExporter/Persistence/FileWriterTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import XCTest
88

99
class FileWriterTests: XCTestCase {
10+
private let temporaryDirectory = obtainUniqueTemporaryDirectory()
11+
1012
override func setUp() {
1113
super.setUp()
1214
temporaryDirectory.create()

Tests/ExportersTests/DatadogExporter/Persistence/FilesOrchestratorTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import XCTest
88

99
class FilesOrchestratorTests: XCTestCase {
1010
private let performance: PerformancePreset = .default
11+
private let temporaryDirectory = obtainUniqueTemporaryDirectory()
1112

1213
override func setUp() {
1314
super.setUp()

Tests/ExportersTests/DatadogExporter/Upload/DataUploadWorkerTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import XCTest
88

99
class DataUploadWorkerTests: XCTestCase {
10+
private let temporaryDirectory = obtainUniqueTemporaryDirectory()
11+
1012
lazy var dateProvider = RelativeDateProvider(advancingBySeconds: 1)
1113
lazy var orchestrator = FilesOrchestrator(
1214
directory: temporaryDirectory,

Tests/ExportersTests/PersistenceExporter/Export/DataExportWorkerTests.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,16 @@ class DataExportWorkerTests: XCTestCase {
146146
}
147147
}
148148

149-
let exportExpectation = self.expectation(description: "value exported")
150-
149+
let exportExpectation = expectation(description: "value exported")
150+
151+
// The onExport closure is called more than once as part of test execution
152+
// It does not seem to be called the same number of times on each test run.
153+
// Setting `assertForOverFulfill` to `false` works around the XCTestExpectation
154+
// error that fails the test.
155+
// "API violation - multiple calls made to -[XCTestExpectation fulfill] for value exported."
156+
exportExpectation.assertForOverFulfill = false
157+
151158
var mockDataExporter = DataExporterMock(exportStatus: .mockWith(needsRetry: true))
152-
153159
mockDataExporter.onExport = { data in exportExpectation.fulfill() }
154160

155161
// When

Tests/ExportersTests/PersistenceExporter/Helpers/TestsDirectory.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func obtainUniqueTemporaryDirectory() -> Directory {
1818

1919
/// `Directory` pointing to subfolder in `/var/folders/`.
2020
/// The subfolder does not exist and can be created and deleted by calling `.create()` and `.delete()`.
21-
let temporaryDirectory = obtainUniqueTemporaryDirectory()
21+
//let temporaryDirectory = obtainUniqueTemporaryDirectory()
2222

2323
/// Extends `Directory` with set of utilities for convenient work with files in tests.
2424
/// Provides handy methods to create / delete files and directires.

Tests/ExportersTests/PersistenceExporter/PersistenceMetricExporterDecoratorTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import OpenTelemetrySdk
99
import XCTest
1010

1111
class PersistenceMetricExporterDecoratorTests: XCTestCase {
12-
12+
private let temporaryDirectory = obtainUniqueTemporaryDirectory()
13+
1314
class MetricExporterMock: MetricExporter {
1415

1516
let onExport: ([Metric]) -> MetricExporterResultCode

Tests/ExportersTests/PersistenceExporter/PersistenceSpanExporterDecoratorTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import OpenTelemetrySdk
99
import XCTest
1010

1111
class PersistenceSpanExporterDecoratorTests: XCTestCase {
12-
12+
private let temporaryDirectory = obtainUniqueTemporaryDirectory()
13+
1314
class SpanExporterMock: SpanExporter {
1415

1516
let onExport: ([SpanData]) -> SpanExporterResultCode

0 commit comments

Comments
 (0)