packer-cn/vendor/github.com/dylanmei/winrmtest
Megan Marsh 5ab31b0363 Revert "vendor vendors"
This reverts commit 8b1fcbb3bd.
2019-10-28 14:31:07 -07:00
..
.gitignore go mod vendor && go mod tidy 2019-04-11 14:19:24 +02: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 Remove LGPL dependencies 2017-08-30 12:10:12 -07: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)
	}
}