tests/Export-SqlServerUpdateScan.test.ps1
Describe "Eport-SqlServerUpdateScan" { It "Test prepare export" { Mock Invoke-SqlServerUpdatesScan { $ClixmlObject = @" <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"> <Obj RefId="0"> <TN RefId="0"> <T>SqlServerUpdates.Instance</T> <T>System.Management.Automation.PSCustomObject</T> <T>System.Object</T> </TN> <MS> <S N="Name">IT-MN-M</S> <S N="Product">Microsoft SQL Server</S> <S N="VersionName">SQL Server 2017</S> <S N="Edition">Developer Edition (64-bit)</S> <S N="ProductLevel">RTM</S> <S N="Build">14.0.1000.169</S> <S N="LatestUpdate">14.0.3257.3</S> <S N="LatestUpdateLink">< a href="https://support.microsoft.com/en-us/help/4527377/cumulative-update-18-for-sql-server-2017"> CU18< /a> </S> <Obj N="Updates" RefId="1"> <TN RefId="1"> <T>System.Object[]</T> <T>System.Array</T> <T>System.Object</T> </TN> <LST> <Obj RefId="2"> <TN RefId="2"> <T>System.Management.Automation.PSCustomObject</T> <T>System.Object</T> </TN> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4527377/cumulative-update-18-for-sql-server-2017"> CU18< /a> </S> <S N="ReleaseDate">2019/12/09</S> <S N="Build">14.0.3257.3</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="3"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4515579/cumulative-update-17-for-sql-server-2017"> CU17< /a> </S> <S N="ReleaseDate">2019/10/08</S> <S N="Build">14.0.3238.1</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="4"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4508218/cumulative-update-16-for-sql-server-2017"> CU16< /a> </S> <S N="ReleaseDate">2019/08/01</S> <S N="Build">14.0.3223.3</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="5"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4505225/security-update-for-sql-server-2017-cu15-gdr-july-9-2019"> Security update< /a> </S> <S N="ReleaseDate">2019/07/09</S> <S N="Build">14.0.3192.2</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="6"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4506633/on-demand-hotfix-update-package-for-sql-server-2017-cu15"> Hotfix< /a> </S> <S N="ReleaseDate">2019/06/21</S> <S N="Build">14.0.3164.1</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="7"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4498951/cumulative-update-15-for-sql-server-2017"> CU15< /a> </S> <S N="ReleaseDate">2019/05/24</S> <S N="Build">14.0.3162.1</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="8"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4484710/cumulative-update-14-for-sql-server-2017"> CU14< /a> </S> <S N="ReleaseDate">2019/03/25</S> <S N="Build">14.0.3076.1</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="9"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4483666/on-demand-hotfix-update-package-for-sql-server-2017-cu13"> Hotfix< /a> </S> <S N="ReleaseDate">2019/01/07</S> <S N="Build">14.0.3049.1</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="10"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4466404/cumulative-update-13-for-sql-server-2017"> CU13< /a> </S> <S N="ReleaseDate">2018/12/18</S> <S N="Build">14.0.3048.4</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="11"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4464082/cumulative-update-12-for-sql-server-2017"> CU12< /a> </S> <S N="ReleaseDate">2018/10/24</S> <S N="Build">14.0.3045.24</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="12"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4462262/cumulative-update-11-for-sql-server-2017"> CU11< /a> </S> <S N="ReleaseDate">2018/09/20</S> <S N="Build">14.0.3038.14</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="13"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4342123/cumulative-update-10-for-sql-server-2017"> CU10< /a> </S> <S N="ReleaseDate">2018/08/27</S> <S N="Build">14.0.3037.1</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="14"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4293805/security-update-for-remote-code-execution-vulnerability-in-sql-server"> GDR2< /a> (security patch to CU9)</S> <S N="ReleaseDate">2018/08/14</S> <S N="Build">14.0.3035.2</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="15"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4341265/cumulative-update-9-for-sql-server-2017"> CU9< /a> </S> <S N="ReleaseDate">2018/07/18</S> <S N="Build">14.0.3030.27</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="16"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4338363/cumulative-update-8-for-sql-server-2017"> CU8< /a> </S> <S N="ReleaseDate">2018/06/20</S> <S N="Build">14.0.3029.16</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="17"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4229789/cumulative-update-7-for-sql-server-2017"> CU7< /a> </S> <S N="ReleaseDate">2018/05/24</S> <S N="Build">14.0.3026.27</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="18"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4101464/cumulative-update-6-for-sql-server-2017"> CU6< /a> </S> <S N="ReleaseDate">2018/04/19</S> <S N="Build">14.0.3025.34</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="19"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4092643/cumulative-update-5-for-sql-server-2017"> CU5< /a> </S> <S N="ReleaseDate">2018/03/20</S> <S N="Build">14.0.3023.8</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="20"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4056498/cumulative-update-4-for-sql-server-2017"> CU4< /a> </S> <S N="ReleaseDate">2018/02/21</S> <S N="Build">14.0.3022.28</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="21"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4052987/cumulative-update-3-for-sql-server-2017"> CU3< /a> </S> <S N="ReleaseDate">2018/01/04</S> <S N="Build">14.0.3015.40</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="22"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4052574/cumulative-update-2-for-sql-server-2017"> CU2< /a> ??(note < a href="http://tracyboggiano.com/archive/2017/12/sql-server-2017-cu2-bug/"> bug< /a> )</S> <S N="ReleaseDate">2017/11/29</S> <S N="Build">14.0.3008.27</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="23"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4038634/cumulative-update-1-for-sql-server-2017"> CU1< /a> </S> <S N="ReleaseDate">2017/10/25</S> <S N="Build">14.0.3006.16</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> <Obj RefId="24"> <TNRef RefId="2" /> <MS> <S N="CumulativeUpdate">< a href="https://support.microsoft.com/en-us/help/4293803/description-of-the-security-update-for-the-remote-code-execution-vulne"> GDR< /a> (security patch to RTM)</S> <S N="ReleaseDate">2018/08/14</S> <S N="Build">14.0.2000.63</S> <S N="SupportEnds">2027/10/12</S> <S N="ServicePack"></S> </MS> </Obj> </LST> </Obj> <B N="ToUpdate">true</B> </MS> </Obj> </Objs> "@ Set-Content -Value $ClixmlObject -Path (New-TemporaryFile -OutVariable TempFile) Import-Clixml -Path $TempFile.FullName | Export-SqlServerUpdatesScan } Mock Out-File { Write-Output $file } Invoke-SqlServerUpdatesScan | Export-SqlServerUpdatesScan | Should Not Be $null } } |