11package construct_test
22
33import (
4+ "fmt"
45 "path/filepath"
56
67 "github.com/cloudfoundry/bosh-windows-stemcell-builder/stembuild/remotemanager"
@@ -10,7 +11,6 @@ import (
1011)
1112
1213var _ = Describe ("WinRM Remote Manager" , func () {
13-
1414 var rm remotemanager.RemoteManager
1515
1616 BeforeEach (func () {
@@ -19,24 +19,30 @@ var _ = Describe("WinRM Remote Manager", func() {
1919 Expect (rm ).ToNot (BeNil ())
2020 })
2121
22- AfterEach (func () {
23- _ , err := rm .ExecuteCommand ("powershell.exe Remove-Item c:\\ provision -recurse" )
24- Expect (err ).ToNot (HaveOccurred ())
25- })
26-
2722 Context ("ExtractArchive" , func () {
23+ var destPath string
24+
2825 BeforeEach (func () {
29- err := rm .UploadArtifact (filepath .Join ("assets" , "StemcellAutomation.zip" ), "C:\\ provision\\ StemcellAutomation.zip" )
26+ destPath = "C:\\ provision"
27+ err := rm .UploadArtifact (
28+ filepath .Join ("assets" , "StemcellAutomation.zip" ),
29+ fmt .Sprintf ("%s\\ StemcellAutomation.zip" , destPath ),
30+ )
31+ Expect (err ).ToNot (HaveOccurred ())
32+ })
33+
34+ AfterEach (func () {
35+ _ , err := rm .ExecuteCommand (fmt .Sprintf ("powershell.exe Remove-Item %s -recurse" , destPath ))
3036 Expect (err ).ToNot (HaveOccurred ())
3137 })
3238
3339 It ("succeeds when Extract-Archive powershell function returns zero exit code" , func () {
34- err := rm .ExtractArchive ("C: \\ provision \\ StemcellAutomation.zip" , "C: \\ provision" )
40+ err := rm .ExtractArchive (fmt . Sprintf ( "%s \\ StemcellAutomation.zip" , destPath ), destPath )
3541 Expect (err ).ToNot (HaveOccurred ())
3642 })
3743
3844 It ("fails when Extract-Archive powershell function returns non-zero exit code" , func () {
39- err := rm .ExtractArchive ("C: \\ provision \\ NonExistingFile.zip" , "C: \\ provision" )
45+ err := rm .ExtractArchive (fmt . Sprintf ( "%s \\ NonExistingFile.zip" , destPath ), destPath )
4046 Expect (err ).To (HaveOccurred ())
4147 Expect (err .Error ()).To (ContainSubstring ("powershell encountered an issue: " ))
4248 })
0 commit comments