mirror of
https://gitlab.durp.info/durfy/modules/gopwsh.git
synced 2026-05-07 08:00:31 -05:00
initial commit
This commit is contained in:
parent
eb87a9c881
commit
6cdb3d2426
6 changed files with 377 additions and 0 deletions
66
shared_test.go
Normal file
66
shared_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue