Skip to content

Add support for provider maps to rules_testing#83

Merged
1 commit merged intomasterfrom
test_606847691
Feb 15, 2024
Merged

Add support for provider maps to rules_testing#83
1 commit merged intomasterfrom
test_606847691

Conversation

@copybara-service
Copy link

Add support for provider maps to rules_testing

Currently, If you are testing a custom provider, the API requires you to write:
env.expect.that_target(targets.foo).provider(FooInfo, factory=FooFactory)...
env.expect.that_target(targets.foo).provider(BarInfo, factory=BarFactory)...

This can get very tedious, and more importantly, is not very safe, since you can write:
env.expect.that_target(targets.foo).provider(FooInfo, factory=FooFactory)...
env.expect.that_target(targets.foo).provider(BarInfo, factory=FooFactory)...

Additionally, custom types are always rendered as "".

To solve this, we add the ability to directly specify a list of factories for custom types in your test.

analysis_test(
...,
provider_factories = [struct(type = FooInfo, name = "FooInfo", factory = FooFactory)]
)

@google-cla
Copy link

google-cla bot commented Feb 14, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@copybara-service copybara-service bot force-pushed the test_606847691 branch 3 times, most recently from f3eb399 to 7c1459e Compare February 15, 2024 03:00
Currently, If you are testing a custom provider, the API requires you to write:
    env.expect.that_target(targets.foo).provider(FooInfo, factory=FooFactory)...
    env.expect.that_target(targets.foo).provider(BarInfo, factory=BarFactory)...

This can get very tedious, and more importantly, is not very safe, since you can write:
    env.expect.that_target(targets.foo).provider(FooInfo, factory=FooFactory)...
    env.expect.that_target(targets.foo).provider(BarInfo, factory=FooFactory)...

Additionally, custom types are always rendered as "<provider>".

To solve this, we add the ability to directly specify a list of factories for custom types in your test.

analysis_test(
    ...,
    provider_factories = [struct(type = FooInfo, name = "FooInfo", factory = FooFactory)]
)

PiperOrigin-RevId: 607174706
@copybara-service copybara-service bot closed this pull request by merging all changes into master in da76c59 Feb 15, 2024
@copybara-service copybara-service bot deleted the test_606847691 branch February 15, 2024 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants