-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhost_test.go
51 lines (47 loc) · 1.24 KB
/
host_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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (C) 2017 Battelle Memorial Institute
// All rights reserved.
//
// This software may be modified and distributed under the terms
// of the BSD-2 license. See the LICENSE file for details.
package ovirtapi_test
import (
"os"
"strconv"
"testing"
"github.com/EMSL-MSC/ovirtapi"
)
func TestHost(t *testing.T) {
username := os.Getenv("OVIRT_USERNAME")
if username == "" {
t.Error("OVIRT_USERNAME is not set")
}
password := os.Getenv("OVIRT_PASSWORD")
if password == "" {
t.Error("OVIRT_PASSWORD is not set")
}
url := os.Getenv("OVIRT_URL")
if url == "" {
t.Error("OVIRT_URL is not set")
}
con, err := ovirtapi.NewConnection(url, username, password, false)
con.Debug, _ = strconv.ParseBool(os.Getenv("DEBUG_TRANSPORT"))
if err != nil {
t.Error("error creating connection", err)
return
}
retrievedHosts, err := con.GetAllHosts()
if err != nil {
t.Fatal("Error retrieving host", err)
}
savedComment := retrievedHosts[0].Comment
retrievedHosts[0].Comment = "testing Description change"
err = retrievedHosts[0].Save()
if err != nil {
t.Fatal("Error updating host", err)
}
retrievedHosts[0].Comment = savedComment
err = retrievedHosts[0].Save()
if err != nil {
t.Fatal("Error reverting description on host", err)
}
}