terraform/vendor/github.com/dylanmei/winrmtest
Radek Simko fdb126f27e
vendor: github.com/dylanmei/winrmtest@99b7fe2fddf1
2019-02-26 18:22:15 +00:00
..
.gitignore
LICENSE
README.md
go.mod vendor: github.com/dylanmei/winrmtest@99b7fe2fddf1 2019-02-26 18:22:15 +00:00
go.sum vendor: github.com/dylanmei/winrmtest@99b7fe2fddf1 2019-02-26 18:22:15 +00:00
remote.go
wsman.go

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)
	}
}