forked from equinixmetal-archive/packngo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
batches_test.go
69 lines (55 loc) · 1.18 KB
/
batches_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
60
61
62
63
64
65
66
67
68
69
package packngo
import (
"testing"
"time"
)
func TestAccInstanceBatches(t *testing.T) {
skipUnlessAcceptanceTestsAllowed(t)
c, projectID, teardown := setupWithProject(t)
defer teardown()
req := &BatchCreateRequest{
Batches: []BatchCreateDevice{
{
DeviceCreateRequest: DeviceCreateRequest{
Hostname: "test1",
Plan: testPlan(),
OS: testOS,
Facility: []string{testFacility()},
BillingCycle: "hourly",
Tags: []string{"abc"},
},
Quantity: 3,
},
},
}
batches, _, err := c.Batches.Create(projectID, req)
if err != nil {
t.Fatal(err)
}
var batchID string
if len(batches) != 0 {
batchID = batches[0].ID
}
batches, _, err = c.Batches.List(projectID, nil)
if err != nil {
t.Fatal(err)
}
if batches == nil {
t.Fatal("No batches have been created")
}
time.Sleep(5 * time.Second)
batch, _, err := c.Batches.Get(batchID, &GetOptions{Includes: []string{"devices"}})
if err != nil {
t.Fatal(err)
}
if batch == nil {
t.Fatal("Batch not found")
}
for _, d := range batch.Devices {
waitDeviceActive(t, c, d.ID)
}
_, err = c.Batches.Delete(batchID, true)
if err != nil {
t.Fatal(err)
}
}