tests/functions/Get-MetadataObjectFromRelease.Tests.ps1


InModuleScope PSDataKit {

    Describe 'Get-MetadataObjectFromRelease' {
        $Env:AGENT_DISABLELOGPLUGIN_TESTFILEPUBLISHERPLUGIN = "AGENT_DISABLELOGPLUGIN_TESTFILEPUBLISHERPLUGIN"
        $Env:AGENT_DISABLELOGPLUGIN_TESTRESULTLOGPLUGIN = "AGENT_DISABLELOGPLUGIN_TESTRESULTLOGPLUGIN"
        $Env:AGENT_HOMEDIRECTORY = "AGENT_HOMEDIRECTORY"
        $Env:AGENT_ID = "AGENT_ID"
        $Env:AGENT_JOBNAME = "AGENT_JOBNAME"
        $Env:AGENT_JOBSTATUS = "AGENT_JOBSTATUS"
        $Env:AGENT_MACHINENAME = "AGENT_MACHINENAME"
        $Env:AGENT_NAME = "AGENT_NAME"
        $Env:AGENT_OS = "AGENT_OS"
        $Env:AGENT_OSARCHITECTURE = "AGENT_OSARCHITECTURE"
        $Env:AGENT_RELEASEDIRECTORY = "AGENT_RELEASEDIRECTORY"
        $Env:AGENT_RETAINDEFAULTENCODING = "AGENT_RETAINDEFAULTENCODING"
        $Env:AGENT_ROOTDIRECTORY = "AGENT_ROOTDIRECTORY"
        $Env:AGENT_SERVEROMDIRECTORY = "AGENT_SERVEROMDIRECTORY"
        $Env:AGENT_TEMPDIRECTORY = "AGENT_TEMPDIRECTORY"
        $Env:AGENT_TOOLSDIRECTORY = "AGENT_TOOLSDIRECTORY"
        $Env:AGENT_VERSION = "AGENT_VERSION"
        $Env:AGENT_WORKFOLDER = "AGENT_WORKFOLDER"
        $Env:BUILD_BUILDID = "BUILD_BUILDID"
        $Env:BUILD_BUILDNUMBER = "BUILD_BUILDNUMBER"
        $Env:BUILD_BUILDURI = "BUILD_BUILDURI"
        $Env:BUILD_DEFINITIONID = "BUILD_DEFINITIONID"
        $Env:BUILD_DEFINITIONNAME = "BUILD_DEFINITIONNAME"
        $Env:BUILD_PROJECTID = "BUILD_PROJECTID"
        $Env:BUILD_PROJECTNAME = "BUILD_PROJECTNAME"
        $Env:BUILD_REPOSITORY_PROVIDER = "BUILD_REPOSITORY_PROVIDER"
        $Env:BUILD_REQUESTEDFOR = "BUILD_REQUESTEDFOR"
        $Env:BUILD_REQUESTEDFORID = "BUILD_REQUESTEDFORID"
        $Env:BUILD_SOURCEBRANCH = "BUILD_SOURCEBRANCH"
        $Env:BUILD_SOURCEBRANCHNAME = "BUILD_SOURCEBRANCHNAME"
        $Env:BUILD_SOURCEVERSION = "BUILD_SOURCEVERSION"
        $Env:BUILD_TYPE = "BUILD_TYPE"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_BUILDID = "RELEASE_ARTIFACTS_INFORMATIONMODEL_BUILDID"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_BUILDNUMBER = "RELEASE_ARTIFACTS_INFORMATIONMODEL_BUILDNUMBER"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_BUILDURI = "RELEASE_ARTIFACTS_INFORMATIONMODEL_BUILDURI"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_DEFINITIONID = "RELEASE_ARTIFACTS_INFORMATIONMODEL_DEFINITIONID"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_DEFINITIONNAME = "RELEASE_ARTIFACTS_INFORMATIONMODEL_DEFINITIONNAME"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_PROJECTID = "RELEASE_ARTIFACTS_INFORMATIONMODEL_PROJECTID"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_PROJECTNAME = "RELEASE_ARTIFACTS_INFORMATIONMODEL_PROJECTNAME"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_REPOSITORY_ID = "RELEASE_ARTIFACTS_INFORMATIONMODEL_REPOSITORY_ID"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_REPOSITORY_NAME = "RELEASE_ARTIFACTS_INFORMATIONMODEL_REPOSITORY_NAME"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_REPOSITORY_PROVIDER = "RELEASE_ARTIFACTS_INFORMATIONMODEL_REPOSITORY_PROVIDER"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_REQUESTEDFOR = "RELEASE_ARTIFACTS_INFORMATIONMODEL_REQUESTEDFOR"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_REQUESTEDFORID = "RELEASE_ARTIFACTS_INFORMATIONMODEL_REQUESTEDFORID"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_SOURCEBRANCH = "RELEASE_ARTIFACTS_INFORMATIONMODEL_SOURCEBRANCH"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_SOURCEBRANCHNAME = "RELEASE_ARTIFACTS_INFORMATIONMODEL_SOURCEBRANCHNAME"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_SOURCEVERSION = "RELEASE_ARTIFACTS_INFORMATIONMODEL_SOURCEVERSION"
        $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_TYPE = "RELEASE_ARTIFACTS_INFORMATIONMODEL_TYPE"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_BUILDID = "RELEASE_ARTIFACTS_MT_PORTAL_BUILDID"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_BUILDNUMBER = "RELEASE_ARTIFACTS_MT_PORTAL_BUILDNUMBER"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_BUILDURI = "RELEASE_ARTIFACTS_MT_PORTAL_BUILDURI"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_DEFINITIONID = "RELEASE_ARTIFACTS_MT_PORTAL_DEFINITIONID"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_DEFINITIONNAME = "RELEASE_ARTIFACTS_MT_PORTAL_DEFINITIONNAME"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_PROJECTID = "RELEASE_ARTIFACTS_MT_PORTAL_PROJECTID"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_PROJECTNAME = "RELEASE_ARTIFACTS_MT_PORTAL_PROJECTNAME"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_REPOSITORY_PROVIDER = "RELEASE_ARTIFACTS_MT_PORTAL_REPOSITORY_PROVIDER"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_REQUESTEDFOR = "RELEASE_ARTIFACTS_MT_PORTAL_REQUESTEDFOR"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_REQUESTEDFORID = "RELEASE_ARTIFACTS_MT_PORTAL_REQUESTEDFORID"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_SOURCEBRANCH = "RELEASE_ARTIFACTS_MT_PORTAL_SOURCEBRANCH"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_SOURCEBRANCHNAME = "RELEASE_ARTIFACTS_MT_PORTAL_SOURCEBRANCHNAME"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_SOURCEVERSION = "RELEASE_ARTIFACTS_MT_PORTAL_SOURCEVERSION"
        $Env:RELEASE_ARTIFACTS_MT_PORTAL_TYPE = "RELEASE_ARTIFACTS_MT_PORTAL_TYPE"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_BUILDID = "RELEASE_ARTIFACTS_TYPEDEFREG_BUILDID"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_BUILDNUMBER = "RELEASE_ARTIFACTS_TYPEDEFREG_BUILDNUMBER"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_BUILDURI = "RELEASE_ARTIFACTS_TYPEDEFREG_BUILDURI"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_DEFINITIONID = "RELEASE_ARTIFACTS_TYPEDEFREG_DEFINITIONID"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_DEFINITIONNAME = "RELEASE_ARTIFACTS_TYPEDEFREG_DEFINITIONNAME"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_PROJECTID = "RELEASE_ARTIFACTS_TYPEDEFREG_PROJECTID"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_PROJECTNAME = "RELEASE_ARTIFACTS_TYPEDEFREG_PROJECTNAME"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_REPOSITORY_ID = "RELEASE_ARTIFACTS_TYPEDEFREG_REPOSITORY_ID"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_REPOSITORY_NAME = "RELEASE_ARTIFACTS_TYPEDEFREG_REPOSITORY_NAME"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_REPOSITORY_PROVIDER = "RELEASE_ARTIFACTS_TYPEDEFREG_REPOSITORY_PROVIDER"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_REQUESTEDFOR = "RELEASE_ARTIFACTS_TYPEDEFREG_REQUESTEDFOR"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_REQUESTEDFORID = "RELEASE_ARTIFACTS_TYPEDEFREG_REQUESTEDFORID"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_SOURCEBRANCH = "RELEASE_ARTIFACTS_TYPEDEFREG_SOURCEBRANCH"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_SOURCEBRANCHNAME = "RELEASE_ARTIFACTS_TYPEDEFREG_SOURCEBRANCHNAME"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_SOURCEVERSION = "RELEASE_ARTIFACTS_TYPEDEFREG_SOURCEVERSION"
        $Env:RELEASE_ARTIFACTS_TYPEDEFREG_TYPE = "RELEASE_ARTIFACTS_TYPEDEFREG_TYPE"
        $Env:RELEASE_ATTEMPTNUMBER = "RELEASE_ATTEMPTNUMBER"
        $Env:RELEASE_DEFINITIONENVIRONMENTID = "RELEASE_DEFINITIONENVIRONMENTID"
        $Env:RELEASE_DEFINITIONID = "RELEASE_DEFINITIONID"
        $Env:RELEASE_DEFINITIONNAME = "RELEASE_DEFINITIONNAME"
        $Env:RELEASE_DEPLOYMENT_REQUESTEDFOR = "RELEASE_DEPLOYMENT_REQUESTEDFOR"
        $Env:RELEASE_DEPLOYMENT_REQUESTEDFOREMAIL = "RELEASE_DEPLOYMENT_REQUESTEDFOREMAIL"
        $Env:RELEASE_DEPLOYMENT_REQUESTEDFORID = "RELEASE_DEPLOYMENT_REQUESTEDFORID"
        $Env:RELEASE_DEPLOYMENT_STARTTIME = "RELEASE_DEPLOYMENT_STARTTIME"
        $Env:RELEASE_DEPLOYMENTID = "RELEASE_DEPLOYMENTID"
        $Env:RELEASE_DEPLOYPHASEID = "RELEASE_DEPLOYPHASEID"
        $Env:RELEASE_ENVIRONMENTID = "RELEASE_ENVIRONMENTID"
        $Env:RELEASE_ENVIRONMENTNAME = "RELEASE_ENVIRONMENTNAME"
        $Env:RELEASE_ENVIRONMENTS_CREATERELEASEMETADATA_STATUS = "RELEASE_ENVIRONMENTS_CREATERELEASEMETADATA_STATUS"
        $Env:RELEASE_ENVIRONMENTURI = "RELEASE_ENVIRONMENTURI"
        $Env:RELEASE_PRIMARYARTIFACTSOURCEALIAS = "RELEASE_PRIMARYARTIFACTSOURCEALIAS"
        $Env:RELEASE_REASON = "RELEASE_REASON"
        $Env:RELEASE_RELEASEDESCRIPTION = "RELEASE_RELEASEDESCRIPTION"
        $Env:RELEASE_RELEASEID = "RELEASE_RELEASEID"
        $Env:RELEASE_RELEASENAME = "RELEASE_RELEASENAME"
        $Env:RELEASE_RELEASEURI = "RELEASE_RELEASEURI"
        $Env:RELEASE_RELEASEWEBURL = "RELEASE_RELEASEWEBURL"
        $Env:RELEASE_REQUESTEDFOR = "RELEASE_REQUESTEDFOR"
        $Env:RELEASE_REQUESTEDFOREMAIL = "RELEASE_REQUESTEDFOREMAIL"
        $Env:RELEASE_REQUESTEDFORID = "RELEASE_REQUESTEDFORID"
        $Env:RELEASE_SKIPARTIFACTSDOWNLOAD = "RELEASE_SKIPARTIFACTSDOWNLOAD"
        $Env:RELEASE_TRIGGERINGARTIFACT_ALIAS = "RELEASE_TRIGGERINGARTIFACT_ALIAS"
        $Env:SYSTEM_TEAMPROJECT = "TEAMPROJECT"
        $Env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = "TEAMFOUNDATIONCOLLECTIONURI"

        Context 'Test generate artficat object' {

            New-Item -ItemType "directory" -Path "TestDrive:\Artifacts"
            New-Item -ItemType "directory" -Path "TestDrive:\Artifacts\InformationModel"
            New-Item -ItemType "directory" -Path "TestDrive:\Artifacts\TypeDefReg"
            New-Item -ItemType "directory" -Path "TestDrive:\Artifacts\MT_PORTAL"

            $metadataObject = Get-MetadataObjectFromRelease -ArtifactsDirectory "TestDrive:\Artifacts"

            $metadataObject.teamfoundationcollectionuri | Should Be $Env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI
            $metadataObject.resources.InformationModel.triggeredBy | Should Be $Env:RELEASE_ARTIFACTS_INFORMATIONMODEL_REQUESTEDFOR
            # Write-Host ($metadataObject | ConvertTo-Json)

        }
    }
}