@@ -33,6 +33,7 @@ Describe "ContainerNetworkTools.psm1" {
3333
3434 Context " Install-WinCNIPlugin" - Tag " Install-WinCNIPlugin" {
3535 BeforeAll {
36+ $Script :ToolName = ' WinCNIPlugin'
3637 $Script :WinCNIRepo = ' https://github.com/microsoft/windows-container-networking/releases/download'
3738 $Script :MockZipFileName = " windows-container-networking-cni-amd64-v1.0.0.zip"
3839 $Script :TestDownloadPath = " $HOME \Downloads\$Script :MockZipFileName "
@@ -47,8 +48,7 @@ Describe "ContainerNetworkTools.psm1" {
4748 Mock Test-EmptyDirectory - ModuleName ' ContainerNetworkTools' - MockWith { return $true }
4849 Mock Install-WinCNIPlugin - ModuleName ' ContainerNetworkTools'
4950 Mock Test-Path - ModuleName ' ContainerNetworkTools' - MockWith { return $true }
50- Mock Invoke-ExecutableCommand - ModuleName ' ContainerNetworkTools' - MockWith {
51- return New-MockObject - Type ' System.Diagnostics.Process' - Properties @ { ExitCode = 0 } }
51+ Mock Install-RequiredFeature - ModuleName ' ContainerNetworkTools'
5252 }
5353
5454 It ' Should not process on implicit request for validation (WhatIfPreference)' {
@@ -69,16 +69,20 @@ Describe "ContainerNetworkTools.psm1" {
6969
7070 Should - Invoke Uninstall-WinCNIPlugin - ModuleName ' ContainerNetworkTools' - Times 0 - Exactly - Scope It
7171 Should - Invoke Get-InstallationFile - ModuleName ' ContainerNetworkTools' - ParameterFilter {
72- $fileParameters [0 ].Feature -eq " WinCNIPlugin " -and
72+ $fileParameters [0 ].Feature -eq " $ Script :ToolName " -and
7373 $fileParameters [0 ].Repo -eq " microsoft/windows-container-networking" -and
7474 $fileParameters [0 ].Version -eq ' latest' -and
7575 $fileParameters [0 ].DownloadPath -eq " $HOME \Downloads"
7676 [string ]::IsNullOrWhiteSpace($fileParameters.ChecksumSchemaFile ) -and
7777 $fileParameters [0 ].FileFilterRegEx -eq $null
7878 }
79- Should - Invoke Invoke-ExecutableCommand - ModuleName ' ContainerNetworkTools' - ParameterFilter {
80- $executable -eq " tar.exe" -and
81- $arguments -eq " -xf `" $Script :TestDownloadPath `" -C `" C:\Program Files\Containerd\cni\bin`" "
79+ Should - Invoke Install-RequiredFeature - ModuleName ' ContainerNetworkTools' - ParameterFilter {
80+ $Feature -eq " $Script :ToolName " -and
81+ $InstallPath -eq " $Env: ProgramFiles \Containerd\cni\bin" -and
82+ $SourceFile -eq " $Script :TestDownloadPath " -and
83+ $EnvPath -eq $null -and
84+ $cleanup -eq $true -and
85+ $UpdateEnvPath -eq $false
8286 }
8387 }
8488
@@ -99,9 +103,12 @@ Describe "ContainerNetworkTools.psm1" {
99103 $fileParameters [0 ].OSArchitecture -eq ' 386' -and
100104 $fileParameters [0 ].FileFilterRegEx -eq " .*tgz(.SHA512)?$"
101105 }
102- Should - Invoke Invoke-ExecutableCommand - ModuleName ' ContainerNetworkTools' - ParameterFilter {
103- $executable -eq " tar.exe" -and
104- $arguments -eq " -xf `" $HOME \Downloads\$MockZipFileName `" -C `" TestDrive:\WinCNI\bin`" "
106+ Should - Invoke Install-RequiredFeature - ModuleName ' ContainerNetworkTools' - ParameterFilter {
107+ $Feature -eq " $Script :ToolName " -and
108+ $InstallPath -eq ' TestDrive:\WinCNI\bin' -and
109+ $SourceFile -eq $MockDownloadFilePath -and
110+ $cleanup -eq $true -and
111+ $UpdateEnvPath -eq $false
105112 }
106113 }
107114
0 commit comments