tests/functions/Get-MetadataObjectFromRelease.Tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

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)

        }
    }
}