Debian Codegraph @

hypervisor/rpc_test.go

raw symbols SCIP
1 // Copyright 2016 The go-qemu Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package hypervisorscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/
16
17 import (
18 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
19 "netscip-go gomod github.com/golang/go/src go1.18 net/"
20 "testingscip-go gomod github.com/golang/go/src go1.18 testing/"
21
22 "github.com/digitalocean/go-libvirt/libvirttestscip-go gomod github.com/digitalocean/go-libvirt 8648fbde413e `github.com/digitalocean/go-libvirt/libvirttest`/"
23 )
24
25 var hvConnscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/hvConn. = func() (netscip-go gomod github.com/golang/go/src go1.18 net/.Connscip-go gomod github.com/golang/go/src go1.18 net/Conn#, error) {
26 m := libvirttestscip-go gomod github.com/digitalocean/go-libvirt 8648fbde413e `github.com/digitalocean/go-libvirt/libvirttest`/.Newscip-go gomod github.com/digitalocean/go-libvirt 8648fbde413e `github.com/digitalocean/go-libvirt/libvirttest`/New().()
27 conn, err := m.Dialscip-go gomod github.com/digitalocean/go-libvirt 8648fbde413e `github.com/digitalocean/go-libvirt/libvirttest`/MockLibvirt#Dial().()
28 return conn, err
29 }
30
31 func TestRPCDriverDomainNamesscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/TestRPCDriverDomainNames().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
32 h := NewRPCDriverscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/NewRPCDriver().(hvConnscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/hvConn.)
33
34 domains, err := h.DomainNamesscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/RPCDriver#DomainNames().()
35 if err != nil {
36 t.Errorscip-go gomod github.com/golang/go/src go1.18 testing/common#Error().(err)
37 }
38
39 wantLen := 2
40 gotLen := len(domains)
41 if gotLen != wantLen {
42 t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected %d domains to be returned, got %d", wantLen, gotLen)
43 }
44
45 for i, name := range domains {
46 wantName := fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("aaaaaaa-%d", i+1)
47 if name != wantName {
48 t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected domain name %q, got %q", wantName, name)
49 }
50 }
51 }
52
53 func TestRPCDriverVersionscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/TestRPCDriverVersion().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
54 h := NewRPCDriverscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/NewRPCDriver().(hvConnscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/hvConn.)
55
56 version, err := h.Versionscip-go gomod github.com/digitalocean/go-qemu . `github.com/digitalocean/go-qemu/hypervisor`/RPCDriver#Version().()
57 if err != nil {
58 t.Errorscip-go gomod github.com/golang/go/src go1.18 testing/common#Error().(err)
59 }
60
61 expected := "1.3.4"
62 if version != expected {
63 t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected version %q, got %q", expected, version)
64 }
65 }