initial commit

This commit is contained in:
DeveloperDurp 2024-10-13 11:38:04 -05:00
parent eb87a9c881
commit 6cdb3d2426
6 changed files with 377 additions and 0 deletions

66
shared_test.go Normal file
View file

@ -0,0 +1,66 @@
package gopwsh
import (
"errors"
"testing"
)
func TestRunPowershellCommand(t *testing.T) {
tests := []struct {
name string
cmd string
expectedErr error
}{
{
name: "test error",
cmd: "irm tgssdcfas.asdfasdf",
expectedErr: errors.New("The remote name could not be resolved: 'tgssdcfas.asdfasdf'"),
},
{
name: "Test working command",
cmd: `get-host`,
expectedErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := RunPowershellCommand(tt.cmd)
if err != nil {
if err.Error() != tt.expectedErr.Error() {
t.Errorf("RunPowershellCommand() error = %v, want error %v", err, tt.expectedErr)
}
}
})
}
}
func TestRunPwshCommand(t *testing.T) {
tests := []struct {
name string
cmd string
expectedErr error
}{
{
name: "test error",
cmd: "irm tgssdcfas.asdfasdf",
expectedErr: errors.New("No such host is known. (tgssdcfas.asdfasdf:80)"),
},
{
name: "Test working command",
cmd: `get-host`,
expectedErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := RunPwshCommand(tt.cmd)
if err != nil {
if err.Error() != tt.expectedErr.Error() {
t.Errorf("RunPwshCommand() error = %v, want error %v", err, tt.expectedErr)
}
}
})
}
}