-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspice_test.go
32 lines (25 loc) · 1.01 KB
/
spice_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package qcli
import "testing"
func TestSpiceDevice(t *testing.T) {
testCases := []struct {
dev Device
out string
}{
{SpiceDevice{Port: "5901"}, "-spice port=5901,addr=127.0.0.1 -device virtio-serial-pci -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent"},
{SpiceDevice{TLSPort: "5902", HostAddress: "0.0.0.0", DisableTicketing: true}, "-spice tls-port=5902,addr=0.0.0.0,disable-ticketing=on -device virtio-serial-pci -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent"},
}
for _, tc := range testCases {
testAppend(tc.dev, tc.out, t)
}
}
func TestSpiceDeviceInvalid(t *testing.T) {
dev := SpiceDevice{}
if err := dev.Valid(); err == nil {
t.Fatalf("A SpiceDevice with missing Port and TLSPort fields is NOT valid")
}
dev.Port = "5901"
dev.TLSPort = "5902"
if err := dev.Valid(); err == nil {
t.Fatalf("A SpiceDevice with both Port and TLSPort fields is NOT valid")
}
}