-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdatacenter_test.go
59 lines (55 loc) · 1.44 KB
/
datacenter_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
52
53
54
55
56
57
58
59
// 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 (
"fmt"
"os"
"strconv"
"testing"
"github.com/EMSL-MSC/ovirtapi"
)
func TestDataCenter(t *testing.T) {
t.Parallel()
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
}
newDataCenter := con.NewDataCenter()
newDataCenter.Name = "test-data-center"
newDataCenter.Local = "true"
err = newDataCenter.Save()
if err != nil {
fmt.Printf("%+v\n", err)
t.Fatal("Error creating new data center", err)
}
retrievedDataCenter, err := con.GetDataCenter(newDataCenter.ID)
if err != nil {
t.Fatal("Error retrieving data center", err)
}
retrievedDataCenter.Description = "about to delete"
err = retrievedDataCenter.Save()
if err != nil {
t.Fatal("Error updating data center", err)
}
err = retrievedDataCenter.Delete()
if err != nil {
t.Fatal("Error Deleting data center", err)
}
}