Skip to content

Verify unirest config in tests #378

@Tazaf

Description

@Tazaf

Is your feature request related to a problem? Please describe.
I'm creating a new UnirestInstance in one of my class constructor and adding general config to it (base URL, headers, etc), and I'd like to write a test that checks that the actual configuration matches the expected one.

Sadly, I apparently can't do that by comparing the properties since there's not getters on the Config instances.

Describe the solution you'd like
I'd like to know if there's a built-in way of comparing two Config objects (for example, one created by hand, the other get from the config() method of a UnirestInstance object).

Describe alternatives you've considered
I thought about testing the config by making a dummy call using MockClient, adding assertions to the mocked client expect() method then calling verifyAll(), but that feels... hacky,

Additional context
Here's a example of what I'd like to achieve:

The manager property being the one that creates the new UnirestInstance and its setup() method configures it.

@Test
public void should_setup_correctly() {
    this.manager.setup();
    Config expected = new Config();
    expected.defaultBaseUrl("https://example.com");
    Config actual = this.manager.unirest.config();
    assertEquals(expected.getBaseUrl(), actual.getBaseUrl());
}

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions