Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing dbs to hosts export #1758

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api-service/service/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func (as *APIService) SearchHostsAsXLSX(filters dto.SearchHostsFilters) (*exceli
"Environment",
"Location",
"Databases",
"Missing Databases",
"Technology",
"Operating System",
"Clust",
Expand Down Expand Up @@ -289,13 +290,17 @@ func (as *APIService) SearchHostsAsXLSX(filters dto.SearchHostsFilters) (*exceli

databases := strings.Builder{}
technology := strings.Builder{}
missingdbs := strings.Builder{}

for k, v := range val.Databases {
databases.WriteString(strings.Join(v, " "))
technology.WriteString(k)
}

missingdbs.WriteString(strings.Join(val.IsMissingDB, " "))

file.SetCellValue(sheet, nextAxis(), databases.String())
file.SetCellValue(sheet, nextAxis(), missingdbs.String())
file.SetCellValue(sheet, nextAxis(), technology.String())

var os string
Expand Down
27 changes: 15 additions & 12 deletions api-service/service/hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ func TestSearchHostsAsXLSX(t *testing.T) {
VirtualizationNode: "",
Cluster: "",
Databases: map[string][]string{},
IsMissingDB: []string{},
},

{
Expand Down Expand Up @@ -620,13 +621,14 @@ func TestSearchHostsAsXLSX(t *testing.T) {
assert.Equal(t, "Italy", sp.GetCellValue("Hosts", "L2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "M2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "N2"))
assert.Equal(t, "Red Hat Enterprise Linux - 7.6", sp.GetCellValue("Hosts", "O2"))
assert.Equal(t, "1", sp.GetCellValue("Hosts", "P2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "Q2"))
assert.Equal(t, "376", sp.GetCellValue("Hosts", "R2"))
assert.Equal(t, "23", sp.GetCellValue("Hosts", "S2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "T2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "O2"))
assert.Equal(t, "Red Hat Enterprise Linux - 7.6", sp.GetCellValue("Hosts", "P2"))
assert.Equal(t, "1", sp.GetCellValue("Hosts", "Q2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "R2"))
assert.Equal(t, "376", sp.GetCellValue("Hosts", "S2"))
assert.Equal(t, "23", sp.GetCellValue("Hosts", "T2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "U2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "V2"))

assert.Equal(t, "test-db", sp.GetCellValue("Hosts", "A3"))
assert.Equal(t, "VMWARE", sp.GetCellValue("Hosts", "B3"))
Expand All @@ -642,13 +644,14 @@ func TestSearchHostsAsXLSX(t *testing.T) {
assert.Equal(t, "Italy", sp.GetCellValue("Hosts", "L2"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "M3"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "N3"))
assert.Equal(t, "Red Hat Enterprise Linux - 7.6", sp.GetCellValue("Hosts", "O3"))
assert.Equal(t, "0", sp.GetCellValue("Hosts", "P3"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "Q3"))
assert.Equal(t, "3", sp.GetCellValue("Hosts", "R3"))
assert.Equal(t, "1", sp.GetCellValue("Hosts", "S3"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "T3"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "O3"))
assert.Equal(t, "Red Hat Enterprise Linux - 7.6", sp.GetCellValue("Hosts", "P3"))
assert.Equal(t, "0", sp.GetCellValue("Hosts", "Q3"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "R3"))
assert.Equal(t, "3", sp.GetCellValue("Hosts", "S3"))
assert.Equal(t, "1", sp.GetCellValue("Hosts", "T3"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "U3"))
assert.Equal(t, "", sp.GetCellValue("Hosts", "V3"))
})

t.Run("Db error", func(t *testing.T) {
Expand Down