packer-cn/vendor/github.com/dylanmei/winrmtest
Chris Bednarski 8a53385cbc Revert "Remove a bunch of unused dependencies (godep v54+ required)"
This reverts commit 9ed133ea01.
2016-02-22 11:44:12 -08:00
..
LICENSE Revert "Remove a bunch of unused dependencies (godep v54+ required)" 2016-02-22 11:44:12 -08:00
README.md Revert "Remove a bunch of unused dependencies (godep v54+ required)" 2016-02-22 11:44:12 -08:00
remote.go Revert "Remove a bunch of unused dependencies (godep v54+ required)" 2016-02-22 11:44:12 -08:00
wsman.go Revert "Remove a bunch of unused dependencies (godep v54+ required)" 2016-02-22 11:44:12 -08:00

README.md

winrmtest

An in-progress testing package to compliment the masterzen/winrm Go-based winrm library.

My primary use-case for this is for dylanmei/packer-communicator-winrm, a Packer communicator plugin for interacting with machines using Windows Remote Management.

Example Use

A fictitious "Windows tools" package.


package wintools

import (
	"io"
	"testing"
	"github.com/dylanmei/winrmtest"
)

func Test_empty_temp_directory(t *testing.T) {
	r := winrmtest.NewRemote()
	defer r.Close()

	r.CommandFunc(wimrmtest.MatchText("dir C:\Temp"), func(out, err io.Writer) int {
		out.Write([]byte(` Volume in drive C is Windows 2012 R2
 Volume Serial Number is XXXX-XXXX

 Directory of C:\

File Not Found`))
		return 0
	})

	lister := NewDirectoryLister(r.Host, r.Port)
	list, _ := lister.TempDirectory()

	if count := len(list.Dirs()); count != 0 {
		t.Errorf("Expected 0 directories but found %d.\n", count)
	}

	if count := len(list.Files()); count != 0 {
		t.Errorf("Expected 0 files but found %d.\n", count)
	}
}