tcldr / Entwine

Testing tools and utilities for Apple's Combine framework.
MIT License
445 stars 26 forks source link

Unable to create `TestScheduler.Configuration` #17

Closed bryanforbes closed 4 years ago

bryanforbes commented 4 years ago

I have a test that had quite a few publishes (7, to be exact) and I wanted to change the configuration to cancel at 1000 rather than 900, but I was unable to create my own configuration because of the following build error:

'TestScheduler.Configuration' initializer is inaccessible due to 'internal' protection level

I believe this will require an explicit init() marked with public for TestScheduler.Configuration.

tcldr commented 4 years ago

Hi Bryan,

Does the following not work for you?

var config = TestScheduler.Configuration.default
config.cancelled = 1000
bryanforbes commented 4 years ago

That works, but then I'm modifying the configuration for all tests instead of just one individual test. In this case, I only want to change it for one test.

tcldr commented 4 years ago

As TestScheduler.Configuration has value semantics (i.e. a basic struct) assigning it to a new var creates a copy of the configuration – the default isn't modified and in fact, can't be, as it's a static let property with value semantics.

bryanforbes commented 4 years ago

I always forget that basic structs use value semantics. Sorry for the momentary lapse in intelligence. The code above works just fine!