beyond-the-cloud-dev / soql-lib

The SOQL Lib provides functional constructs for SOQL queries in Apex.
https://soql.beyondthecloud.dev/
MIT License
63 stars 10 forks source link

Removing requirement of ContactsToMultipleAccounts (AccountContactRelation) Feature to pass tests #77

Closed mgellada-sd closed 1 year ago

mgellada-sd commented 1 year ago

This has caused much headache with org deployment of using this great library! This is a feature that is not enabled and not planned to enable for org deployment. Is there a way to remove this requirement by changing tests to use something else that can exhibit same testing behavior so that this feature does not need to be enabled for deployment and running tests?

mgellada-sd commented 1 year ago

Here's my suggested change in SOQL_Test.cls. I've gone ahead and forked into my private repo

    @IsTest
    static void inlcudesAll() {
        // Setup
        List<String> ratings = new List<String>{ 'Hot', 'Warm' };

        // Test
        SOQL builder = SOQL.of(Account.SObjectType)
            .with(Account.Id)
            .whereAre(SOQL.Filter.with(Account.Rating).includesAll(ratings));

        // Verify
        String soql = builder.toString();
        Assert.areEqual('SELECT Id FROM Account WHERE Rating INCLUDES (\'Hot;Warm\')', soql);
    }

    @IsTest
    static void inlcudesSome() {
        // Setup
        List<String> ratings = new List<String>{ 'Hot', 'Warm' };

        // Test
        SOQL builder = SOQL.of(Account.SObjectType)
            .with(Account.Id)
            .whereAre(SOQL.Filter.with(Account.Rating).includesSome(ratings));

        // Verify
        String soql = builder.toString();
        Assert.areEqual('SELECT Id FROM Account WHERE Rating INCLUDES (\'Hot\', \'Warm\')', soql);
    }

    @IsTest
    static void excludesAll() {
        // Setup
        List<String> ratings = new List<String>{ 'Hot', 'Warm' };

        // Test
        SOQL builder = SOQL.of(Account.SObjectType)
            .with(Account.Id)
            .whereAre(SOQL.Filter.with(Account.Rating).excludesAll(ratings));

        // Verify
        String soql = builder.toString();
        Assert.areEqual('SELECT Id FROM Account WHERE Rating EXCLUDES (\'Hot\', \'Warm\')', soql);
    }

    @IsTest
    static void excludesSome() {
        // Setup
        List<String> ratings = new List<String>{ 'Hot', 'Warm' };

        // Test
        SOQL builder = SOQL.of(Account.SObjectType)
            .with(Account.Id)
            .whereAre(SOQL.Filter.with(Account.Rating).excludesSome(ratings));

        // Verify
        String soql = builder.toString();
        Assert.areEqual('SELECT Id FROM Account WHERE Rating EXCLUDES (\'Hot;Warm\')', soql);
    }
pgajek2 commented 1 year ago

Thanks @mgellada-sd! Great point!

I see two options:

  1. I can change it by myself
  2. Or you can create PR from your forked repository

Let's me know what do you prefer :D

mgellada-sd commented 1 year ago

Just submitted a PR! @pgajek2

pgajek2 commented 1 year ago

Deployed! Thanks for collaboration @mgellada-sd 🫡