Kolos65 / Mockable

A Swift macro driven auto-mocking library.
MIT License
199 stars 14 forks source link

Package is using API from Combine with iOS 15 but Package.swift requires iOS 13 #40

Closed mihaicris-adoreme closed 3 months ago

mihaicris-adoreme commented 3 months ago

Minimum deployment version iOS should be iOS 15 because package is using Combine API with minimum iOS 15. $_invocations.receive(on: queue).values

    public func verify(_ member: Member,
                       count: Count,
                       assertion: @escaping MockableAssertion,
                       timeout: TimeoutDuration,
                       file: StaticString = #file,
                       line: UInt = #line) async {
        do {
            let invocationsSequence = $_invocations.receive(on: queue).values
            try await withTimeout(after: timeout.duration) {
                for await invocations in invocationsSequence {
                    let matches = invocations.filter(member.match)
                    if count.satisfies(matches.count) {
                        break
                    } else {
                        continue
                    }
                }
            }
        } catch {
            let matches = invocations.filter(member.match)
            let message = """
            Expected \(count) invocation(s) of \(member.name) before \(timeout.duration)s, but was: \(matches.count)
            """
            assertion(count.satisfies(matches.count), message, file, line)
        }
    }
hainayanda commented 3 months ago

@Kolos65 I think if you want to support iOS 13.0 you will need to use a solution similar to what I did originally.

Kolos65 commented 3 months ago

Already put up a fix in #42

The only problem was the values prop which could be easily implemented with an AsyncStream.

Kolos65 commented 3 months ago

Fixed in 0.0.7