diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3298c543f..d4c6c5936 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -184,12 +184,12 @@ jobs: # This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). # Utlimately, this could/should probably be better mocked during tests, but the AuthSession is read-only in Apex, so it's a bit difficult to work with. # Running the Apex tests sync & async serves as an extra level of integration testing to ensure that everything works with or without an active session. + - name: 'Run Apex Tests Synchronously' + run: npm run test:apex:nocoverage -- --synchronous + - name: 'Run Apex Tests Asynchronously' run: npm run test:apex:nocoverage - - name: 'Run Apex Tests Synchronously' - run: npm run test:apex -- --synchronous - - name: 'Delete Scratch Org' run: npx sf org delete scratch --no-prompt if: ${{ always() }} @@ -252,12 +252,13 @@ jobs: # This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). # Utlimately, this could/should probably be better mocked during tests, but the AuthSession is read-only in Apex, so it's a bit difficult to work with. # Running the Apex tests sync & async serves as an extra level of integration testing to ensure that everything works with or without an active session. - - name: 'Run Apex Tests Asynchronously' - run: npm run test:apex:nocoverage - - name: 'Run Apex Tests Synchronously' run: npm run test:apex:nocoverage -- --synchronous + # This intentionally does NOT use test:apex:nocoverage, since code coverage results are uploaded below to codecov.io + - name: 'Run Apex Tests Asynchronously' + run: npm run test:apex + # This is the only scratch org that's used for uploading code coverage - name: 'Upload Apex test code coverage to Codecov.io' uses: codecov/codecov-action@v4 @@ -328,12 +329,12 @@ jobs: # This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). # Utlimately, this could/should probably be better mocked during tests, but the AuthSession is read-only in Apex, so it's a bit difficult to work with. # Running the Apex tests sync & async serves as an extra level of integration testing to ensure that everything works with or without an active session. - - name: 'Run Apex Tests Asynchronously' - run: npm run test:apex:nocoverage - - name: 'Run Apex Tests Synchronously' run: npm run test:apex:nocoverage -- --synchronous + - name: 'Run Apex Tests Asynchronously' + run: npm run test:apex:nocoverage + - name: 'Delete Scratch Org' run: npx sf org delete scratch --no-prompt if: ${{ always() }} @@ -399,12 +400,12 @@ jobs: # This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). # Utlimately, this could/should probably be better mocked during tests, but the AuthSession is read-only in Apex, so it's a bit difficult to work with. # Running the Apex tests sync & async serves as an extra level of integration testing to ensure that everything works with or without an active session. - - name: 'Run Apex Tests Asynchronously' - run: npm run test:apex:nocoverage - - name: 'Run Apex Tests Synchronously' run: npm run test:apex:nocoverage -- --synchronous + - name: 'Run Apex Tests Asynchronously' + run: npm run test:apex:nocoverage + - name: 'Delete Scratch Org' run: npx sf org delete scratch --no-prompt if: ${{ always() }} @@ -474,12 +475,12 @@ jobs: # This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). # Utlimately, this could/should probably be better mocked during tests, but the AuthSession is read-only in Apex, so it's a bit difficult to work with. # Running the Apex tests sync & async serves as an extra level of integration testing to ensure that everything works with or without an active session. - - name: 'Run Apex Tests Asynchronously' - run: npm run test:apex:nocoverage - - name: 'Run Apex Tests Synchronously' run: npm run test:apex:nocoverage -- --synchronous + - name: 'Run Apex Tests Asynchronously' + run: npm run test:apex:nocoverage + - name: 'Delete Base Scratch Org' run: npx sf org delete scratch --no-prompt if: ${{ always() }} @@ -542,12 +543,12 @@ jobs: # This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). # Utlimately, this could/should probably be better mocked during tests, but the AuthSession is read-only in Apex, so it's a bit difficult to work with. # Running the Apex tests sync & async serves as an extra level of integration testing to ensure that everything works with or without an active session. - - name: 'Run Apex Tests Asynchronously' - run: npm run test:apex:nocoverage - - name: 'Run Apex Tests Synchronously' run: npm run test:apex:nocoverage -- --synchronous + - name: 'Run Apex Tests Asynchronously' + run: npm run test:apex:nocoverage + - name: 'Delete Scratch Org' run: npx sf org delete scratch --no-prompt if: ${{ always() }} @@ -657,12 +658,12 @@ jobs: # This is done because, based on how you execute Apex tests, the running user may have an active session (synchrously) or not (asynchronously). # Utlimately, this could/should probably be better mocked during tests, but the AuthSession is read-only in Apex, so it's a bit difficult to work with. # Running the Apex tests sync & async serves as an extra level of integration testing in the meantime to ensure that everything works with or without an active session. - - name: 'Run Apex Tests Asynchronously' - run: npm run test:apex:nocoverage -- --targetusername nebula-logger-package-demo - - name: 'Run Apex Tests Synchronously' run: npm run test:apex:nocoverage -- --targetusername nebula-logger-package-demo --synchronous + - name: 'Run Apex Tests Asynchronously' + run: npm run test:apex:nocoverage -- --targetusername nebula-logger-package-demo + - name: 'Commit New Package Version' if: ${{ github.event_name == 'pull_request' }} run: | diff --git a/nebula-logger/core/tests/configuration/classes/LoggerConfigurationDataSelector_Tests.cls b/nebula-logger/core/tests/configuration/classes/LoggerConfigurationDataSelector_Tests.cls index e23f2f44a..eceff701f 100644 --- a/nebula-logger/core/tests/configuration/classes/LoggerConfigurationDataSelector_Tests.cls +++ b/nebula-logger/core/tests/configuration/classes/LoggerConfigurationDataSelector_Tests.cls @@ -6,9 +6,27 @@ @SuppressWarnings('PMD.ApexDoc, PMD.ApexAssertionsShouldIncludeMessage, PMD.MethodNamingConventions') @IsTest(IsParallel=true) private class LoggerConfigurationDataSelector_Tests { - static { - // Don't use the org's actual custom metadata records when running tests + @IsTest + static void it_initializes_mock_lists_when_use_mocks_is_called() { + System.Assert.isNull(LoggerConfigurationDataSelector.mockLogEntryDataMaskRules); + System.Assert.isNull(LoggerConfigurationDataSelector.mockLogEntryTagRules); + System.Assert.isNull(LoggerConfigurationDataSelector.mockLoggerFieldMappings); + System.Assert.isNull(LoggerConfigurationDataSelector.mockLoggerParameters); + System.Assert.isNull(LoggerConfigurationDataSelector.mockLoggerPlugins); + System.Assert.isNull(LoggerConfigurationDataSelector.mockLoggerScenarioRules); + System.Assert.isNull(LoggerConfigurationDataSelector.mockLoggerSObjectHandlers); + System.Assert.isNull(LoggerConfigurationDataSelector.mockLogStatuses); + LoggerConfigurationDataSelector.useMocks(); + + System.Assert.areEqual(new List(), LoggerConfigurationDataSelector.mockLogEntryDataMaskRules); + System.Assert.areEqual(new List(), LoggerConfigurationDataSelector.mockLogEntryTagRules); + System.Assert.areEqual(new List(), LoggerConfigurationDataSelector.mockLoggerFieldMappings); + System.Assert.areEqual(new Map(), LoggerConfigurationDataSelector.mockLoggerParameters); + System.Assert.areEqual(new List(), LoggerConfigurationDataSelector.mockLoggerPlugins); + System.Assert.areEqual(new List(), LoggerConfigurationDataSelector.mockLoggerScenarioRules); + System.Assert.areEqual(new List(), LoggerConfigurationDataSelector.mockLoggerSObjectHandlers); + System.Assert.areEqual(new List(), LoggerConfigurationDataSelector.mockLogStatuses); } @IsTest @@ -86,7 +104,7 @@ private class LoggerConfigurationDataSelector_Tests { @IsTest static void it_returns_logger_parameters_from_database() { - Map expectedValues = LoggerParameter__mdt.getAll(); + Map expectedValues = LoggerParameter__mdt.getAll().deepClone(); Map returnedValues = LoggerConfigurationDataSelector.getInstance().getLoggerParameters(); @@ -149,11 +167,9 @@ private class LoggerConfigurationDataSelector_Tests { FROM LoggerSObjectHandler__mdt WHERE IsEnabled__c = TRUE ]; - System.Assert.isFalse(expectedValues.isEmpty()); List returnedValues = LoggerConfigurationDataSelector.getInstance().getLoggerSObjectHandlers(); - System.Assert.isFalse(returnedValues.isEmpty()); System.Assert.areEqual(expectedValues, returnedValues); } @@ -171,11 +187,9 @@ private class LoggerConfigurationDataSelector_Tests { @IsTest static void it_returns_log_statuses_from_database() { List expectedValues = LogStatus__mdt.getAll().values().deepClone(); - System.Assert.isFalse(expectedValues.isEmpty()); List returnedValues = LoggerConfigurationDataSelector.getInstance().getLogStatuses(); - System.Assert.isFalse(returnedValues.isEmpty()); System.Assert.areEqual(expectedValues, returnedValues); }