-
Notifications
You must be signed in to change notification settings - Fork 57
/
inventory_update_test.go
133 lines (130 loc) · 3.95 KB
/
inventory_update_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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package awx
import (
"testing"
"time"
)
func TestGetInventoryUpdate(t *testing.T) {
var (
expectInventoryUpdateResponse = &InventoryUpdate{
Status: "successful",
ID: 305,
Type: "inventory_update",
URL: "/api/v2/inventory_updates/305/",
Related: &Related{
CreatedBy: "/api/v2/users/5/",
ModifiedBy: "/api/v2/users/5/",
UnifiedJobTemplate: "/api/v2/inventory_sources/10/",
Stdout: "/api/v2/inventory_updates/305/stdout/",
InventorySource: "/api/v2/inventory_sources/10/",
Cancel: "/api/v2/inventory_updates/305/cancel/",
Notifications: "/api/v2/inventory_updates/305/notifications/",
Events: "/api/v2/inventory_updates/305/events/",
Inventory: "/api/v2/inventories/1/",
Credentials: "/api/v2/inventory_updates/305/credentials/",
},
SummaryFields: &Summary{
Organization: &OrgnizationSummary{
ID: 1,
Name: "Default",
Description: "",
},
Inventory: &Inventory{
ID: 1,
Name: "Default",
Description: "",
HasActiveFailures: true,
TotalHosts: 7,
HostsWithActiveFailures: 6,
TotalGroups: 14,
HasInventorySources: true,
TotalInventorySources: 1,
InventorySourcesWithFailures: 0,
OrganizationID: 1,
Kind: "",
},
UnifiedJobTemplate: &UnifiedJobTemplate{
ID: 10,
Name: "Default",
Description: "",
UnifiedJobType: "inventory_update",
},
InventorySource: &InventorySource{
Source: "scm",
LastUpdated: func() time.Time {
t, _ := time.Parse(time.RFC3339, "2021-07-30T10:12:44.553099Z")
return t
}(),
Status: "pending",
},
CreatedBy: &ByUserSummary{
ID: 5,
Username: "admin",
FirstName: "",
LastName: "",
},
ModifiedBy: &ByUserSummary{
ID: 5,
Username: "admin",
FirstName: "",
LastName: "",
},
UserCapabilities: &UserCapabilities{
Delete: true,
Start: true,
},
Credentials: []Credential{},
},
Created: func() time.Time {
t, _ := time.Parse(time.RFC3339, "2021-08-02T01:45:22.144755Z")
return t
}(),
Modified: func() time.Time {
t, _ := time.Parse(time.RFC3339, "2021-08-02T01:45:22.157220Z")
return t
}(),
Name: "Default",
Description: "",
Source: "scm",
SourcePath: "",
SourceScript: nil,
SourceVars: "",
Credential: nil,
EnabledVar: "",
EnabledValue: "",
HostFilter: "",
Overwrite: true,
OverwriteVars: true,
CustomVirtualenv: nil,
Timeout: 0,
Verbosity: 2,
UnifiedJobTemplate: 10,
LaunchType: "manual",
Failed: false,
Started: nil,
Finished: nil,
CanceledOn: nil,
Elapsed: 0.0,
JobArgs: "",
JobCwd: "",
JobEnv: nil,
JobExplanation: "",
ExecutionNode: "",
ResultTraceback: "",
EventProcessingFinished: false,
Inventory: 1,
LicenseError: false,
OrgHostLimitError: false,
SourceProjectUpdate: nil,
SourceProject: nil,
InventoryUpdate: 305,
}
)
awx := NewAWX(testAwxHost, testAwxUserName, testAwxPasswd, nil)
result, err := awx.InventoryUpdatesService.GetInventoryUpdate(305, map[string]string{})
if err != nil {
t.Fatalf("GetInventoryUpdate err: %s", err)
} else {
checkAPICallResult(t, expectInventoryUpdateResponse, result)
t.Log("GetInventoryUpdate passed!")
}
}