diff --git a/SfHelper.psd1 b/SfHelper.psd1 index eac73f6..452492c 100644 --- a/SfHelper.psd1 +++ b/SfHelper.psd1 @@ -51,7 +51,7 @@ Description = 'Powershell module to help query Salesforce' # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module -RequiredModules = @(@{ModuleName="InvokeHelper"; ModuleVersion="1.2.1"}) +RequiredModules = @(@{ModuleName="InvokeHelper"; ModuleVersion="1.2.2"}) # Assemblies that must be loaded prior to importing this module # RequiredAssemblies = @() diff --git a/Test/include/config.mock.ps1 b/Test/include/config.mock.ps1 index 4a131ef..d450b7f 100644 --- a/Test/include/config.mock.ps1 +++ b/Test/include/config.mock.ps1 @@ -1,5 +1,18 @@ -$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-SfGetConfigRootPath" +# CONFIG MOCK +# +# This file is used to mock the config path and the config file +# for the tests. It creates a mock config path and a mock config file +# and sets the config path to the mock config path. +# We need to define varaibles for this include to work +# $MOCK_CONFIG_PATH : The path use as the mock config folder +# $CONFIG_INVOKE_GET_ROOT_PATH_CMD : Invoke comand that is needed to be mocked +# +# Sample file +# # CONFIG MOCK VARIABLES +# # This file is required for CONFIF MOCK to work +# $CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-SfGetConfigRootPath" +# $MOCK_CONFIG_PATH = "test_config_path" function Mock_Config{ param( diff --git a/Test/include/database.mock.ps1 b/Test/include/database.mock.ps1 index b64721b..8b18c98 100644 --- a/Test/include/database.mock.ps1 +++ b/Test/include/database.mock.ps1 @@ -1,5 +1,20 @@ - -$DB_INVOKE_GET_ROOT_PATH_CMD = "Invoke-SfGetDbRootPath" +# DATABASE MOCK +# +# This file is used to mock the database path and the database file +# for the tests. It creates a mock database path and a mock database file +# and sets the database path to the mock database path. +# We need to define variables for this include to work +# $MOCK_DATABASE_PATH : The path used as the mock database folder +# $DB_INVOKE_GET_ROOT_PATH_CMD : Invoke command that is needed to be mocked +# $DB_INVOKE_GET_ROOT_PATH_ALIAS : Invoke function to retreive the root path of the database +# +# Sample file +# # DATABASE MOCK VARIABLES +# # This file is required for DATABASE MOCK to work +# $DB_INVOKE_GET_ROOT_PATH_CMD = "Invoke-SfGetDbRootPath" +# $DB_INVOKE_GET_ROOT_PATH_ALIAS = "SfGetDbRootPath" +# +# $MOCK_DATABASE_PATH = "test_database_path" function Mock_Database([switch]$ResetDatabase){ @@ -17,4 +32,16 @@ function Mock_Database([switch]$ResetDatabase){ function Get-Mock_DatabaseStore{ $dbstore = Invoke-MyCommand -Command $DB_INVOKE_GET_ROOT_PATH_CMD return $dbstore +} + +function Reset-DatabaseStore{ + [CmdletBinding()] + param() + + $databaseRoot = Invoke-MyCommand -Command $DB_INVOKE_GET_ROOT_PATH_ALIAS + + Remove-Item -Path $databaseRoot -Recurse -Force -ErrorAction SilentlyContinue + + New-Item -Path $databaseRoot -ItemType Directory + } \ No newline at end of file diff --git a/Test/private/include.config.mock.sf.ps1 b/Test/private/include.config.mock.sf.ps1 new file mode 100644 index 0000000..ffe2a65 --- /dev/null +++ b/Test/private/include.config.mock.sf.ps1 @@ -0,0 +1,5 @@ +# CONFIG MOCK VARIABLES +# This file is required for CONFIF MOCK to work + +$MOCK_CONFIG_PATH = "test_config_path" +$CONFIG_INVOKE_GET_ROOT_PATH_CMD = "Invoke-SfGetConfigRootPath" diff --git a/Test/private/include.databasev2.mock.sf.ps1 b/Test/private/include.databasev2.mock.sf.ps1 new file mode 100644 index 0000000..e50fe2b --- /dev/null +++ b/Test/private/include.databasev2.mock.sf.ps1 @@ -0,0 +1,7 @@ +# DATABASEV2 MOCK VARIABLES +# This file is required for DATABASEV2 MOCK to work + +$DB_INVOKE_GET_ROOT_PATH_ALIAS = "SfGetDbRootPath" +$DB_INVOKE_GET_ROOT_PATH_CMD = "Invoke-SfGetDbRootPath" +$MOCK_DATABASE_PATH = "test_database_path" + diff --git a/Test/private/mock_variables.ps1 b/Test/private/mock_variables.ps1 index 972f028..a8bd9f9 100644 --- a/Test/private/mock_variables.ps1 +++ b/Test/private/mock_variables.ps1 @@ -3,4 +3,6 @@ $MODULE_INVOKATION_TAG = "SfHelperModule" $MODULE_INVOKATION_TAG_MOCK = "SfHelperModule-Mock" + +# SetMockPath $MOCK_PATH = $PSScriptRoot | Split-Path -Parent | Join-Path -ChildPath 'private' -AdditionalChildPath 'mocks' \ No newline at end of file diff --git a/private/mySetInvokeCommandAlias_Varaibles.ps1.ps1 b/private/include.mySetInvokeCommandAlias.sf.ps1.ps1 similarity index 100% rename from private/mySetInvokeCommandAlias_Varaibles.ps1.ps1 rename to private/include.mySetInvokeCommandAlias.sf.ps1.ps1 diff --git a/public/sfconfig.ps1 b/public/include.config.sf.ps1 similarity index 100% rename from public/sfconfig.ps1 rename to public/include.config.sf.ps1 diff --git a/public/include.databasev2.sf.ps1 b/public/include.databasev2.sf.ps1 new file mode 100644 index 0000000..215dc86 --- /dev/null +++ b/public/include.databasev2.sf.ps1 @@ -0,0 +1,15 @@ +# This file is required for INCLUDE DATABASE V2 + +$DB_INVOKE_GET_ROOT_PATH_ALIAS = "SfGetDbRootPath" +$DB_INVOKE_GET_ROOT_PATH_CMD = "Invoke-SfGetDbRootPath" + +Set-MyInvokeCommandAlias -Alias $DB_INVOKE_GET_ROOT_PATH_ALIAS -Command $DB_INVOKE_GET_ROOT_PATH_CMD + +function Invoke-SfGetDbRootPath{ + [CmdletBinding()] + param() + + $databaseRoot = GetDatabaseRootPath + return $databaseRoot + +} Export-ModuleMember -Function Invoke-SfGetDbRootPath \ No newline at end of file diff --git a/public/sfDatabase.ps1 b/public/sfDatabase.ps1 deleted file mode 100644 index 19452f1..0000000 --- a/public/sfDatabase.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -# This file is required for INCLUDE DATABASE V2 - -$DB_INVOKE_GET_ROOT_PATH_ALIAS = "SfGetDbRootPath" -$DB_INVOKE_GET_ROOT_PATH_CMD = "Invoke-SfGetDbRootPath" - -Set-MyInvokeCommandAlias -Alias $DB_INVOKE_GET_ROOT_PATH_ALIAS -Command $DB_INVOKE_GET_ROOT_PATH_CMD - -function Invoke-SfGetDbRootPath{ - [CmdletBinding()] - param() - - $databaseRoot = GetDatabaseRootPath - return $databaseRoot - -} Export-ModuleMember -Function Invoke-SfGetDbRootPath - -# Extra functions not needed by INCLUDE DATABASE V2 - -function Reset-DatabaseStore{ - [CmdletBinding()] - param() - - $databaseRoot = Invoke-MyCommand -Command $DB_INVOKE_GET_ROOT_PATH_ALIAS - - Remove-Item -Path $databaseRoot -Recurse -Force -ErrorAction SilentlyContinue - - New-Item -Path $databaseRoot -ItemType Directory - -} Export-ModuleMember -Function Reset-DatabaseStore \ No newline at end of file