Skip to content

Commit

Permalink
Add ansiblehost to test and mock
Browse files Browse the repository at this point in the history
  • Loading branch information
justinorringer committed Feb 27, 2024
1 parent 1c9d937 commit 5583ad4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/api/connectors/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (this *inventoryConnectorImpl) GetHostConnectionDetails(ctx context.Context
satelliteFacts := getSatelliteFacts(host.Facts)
hostConnectionDetails[i] = HostDetails{
ID: *host.Id,
AnsibleHost: host.AnsibleHost,
OwnerID: systemProfileResults[*host.Id].SystemProfile.OwnerId,
SatelliteInstanceID: satelliteFacts.SatelliteInstanceID,
SatelliteVersion: satelliteFacts.SatelliteVersion,
Expand Down
2 changes: 2 additions & 0 deletions internal/api/connectors/inventory/inventory_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ func (this *inventoryConnectorMock) GetHostConnectionDetails(
satelliteOrgID := "5"
satelliteVersion := "6.11"
rhcClientID := "32af5948-301f-449a-a25b-ff34c83264a2"
ansibleHost := "host1.mydomain.com"

hostDetails := HostDetails{
ID: "c484f980-ab8d-401b-90e7-aa1d4ccf8c0e",
OwnerID: &ownerID,
SatelliteInstanceID: &satelliteInstanceID,
SatelliteVersion: &satelliteVersion,
SatelliteOrgID: &satelliteOrgID,
AnsibleHost: &ansibleHost,
}

directConnectDetails := HostDetails{
Expand Down
4 changes: 4 additions & 0 deletions internal/api/connectors/inventory/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var _ = Describe("Inventory", func() {
Expect(*resultData.SatelliteVersion).To(Equal("6.11.3"))
Expect(*resultData.SatelliteOrgID).To(Equal("5"))
Expect(*resultData.RHCClientID).To(Equal("7bc66a39-e719-4bc5-b10a-77bfbd3a0ead"))
Expect(resultData.AnsibleHost).ToNot(BeNil())
Expect(*resultData.AnsibleHost).To(Equal("host1.mydomain.com"))
})

It("Interperates response correctly on unexpected status code from hostDetails", func() {
Expand Down Expand Up @@ -81,6 +83,7 @@ var _ = Describe("Inventory", func() {
Expect(resultData.SatelliteInstanceID).To(BeNil())
Expect(resultData.SatelliteVersion).To(BeNil())
Expect(resultData.SatelliteOrgID).To(BeNil())
Expect(resultData.AnsibleHost).To(BeNil())
Expect(*resultData.RHCClientID).To(Equal("7bc66a39-e719-4bc5-b10a-77bfbd3a0ead"))
})

Expand All @@ -102,6 +105,7 @@ var _ = Describe("Inventory", func() {
Expect(*resultData.SatelliteInstanceID).To(Equal("5678"))
Expect(*resultData.SatelliteVersion).To(Equal("6.11.3"))
Expect(*resultData.SatelliteOrgID).To(Equal("5"))
Expect(*resultData.AnsibleHost).To(Equal("host1.mydomain.com"))
Expect(resultData.RHCClientID).To(BeNil())
})
})
Expand Down
1 change: 1 addition & 0 deletions internal/api/connectors/inventory/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type HostDetails struct {
SatelliteVersion *string `json:"satellite_version,omitempty"`
SatelliteOrgID *string `json:"satellite_org_id,omitempty"`
RHCClientID *string `json:"rhc_client_id,omitempty"`
AnsibleHost *string `json:"ansible_host,omitempty"`
}

type InventoryConnector interface {
Expand Down

0 comments on commit 5583ad4

Please sign in to comment.