Skip to content

Commit

Permalink
Merge pull request #627 from ystia/bugfix/GH-625-location-without-props
Browse files Browse the repository at this point in the history
Display location without properties
  • Loading branch information
stebenoist committed Apr 1, 2020
2 parents f702398 + dd9073b commit ca50829
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## UNRELEASED

### BUG FIXES

* Location is not listed if its properties are missing ([GH-625](https://github.com/ystia/yorc/issues/625))

## 4.0.0-rc.1 (March 30, 2020)

### FEATURES
Expand Down
10 changes: 7 additions & 3 deletions commands/locations/locations_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ func listLocations(client httputil.HTTPClient) error {

func displayLocationInfo(table tabutil.Table, locationName, locationType string, properties config.DynamicMap, colorize bool, operation int) {
propKeys := properties.Keys()
for i := 0; i < len(propKeys); i++ {
propValue := properties.Get(propKeys[i])
displayProperties(table, locationName, locationType, i, propKeys[i], propValue, 0, colorize, operation)
if len(propKeys) > 0 {
for i := 0; i < len(propKeys); i++ {
propValue := properties.Get(propKeys[i])
displayProperties(table, locationName, locationType, i, propKeys[i], propValue, 0, colorize, operation)
}
} else {
displayRow(table, locationName, locationType, 0, "", "", 0, false, 0)
}
}

Expand Down
14 changes: 13 additions & 1 deletion commands/locations/locations_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ func (c *httpClientMockList) Do(req *http.Request) (*http.Response, error) {
w := httptest.NewRecorder()

if req.URL.Path == "/locations" {
locations := &rest.LocationCollection{Locations: []rest.AtomLink{{Rel: "location", Href: "/locations/locationOne", LinkType: rest.LinkRelHost}}}
locations := &rest.LocationCollection{Locations: []rest.AtomLink{
{Rel: "location", Href: "/locations/locationOne", LinkType: rest.LinkRelHost},
{Rel: "location", Href: "/locations/locationTwo", LinkType: rest.LinkRelHost},
}}
b, err := json.Marshal(locations)
if err != nil {
return nil, errors.New("Failed to build MockList http client response")
Expand Down Expand Up @@ -83,6 +86,15 @@ func (c *httpClientMockList) Do(req *http.Request) (*http.Response, error) {
w.Write(b)
}

if req.URL.Path == "/locations/locationTwo" {
locationConfig := &rest.LocationConfiguration{Name: "location3", Type: "slurm"}
b, err := json.Marshal(locationConfig)
if err != nil {
return nil, errors.New("Failed to build Mock http client response")
}
w.Write(b)
}

return w.Result(), nil
}

Expand Down

0 comments on commit ca50829

Please sign in to comment.