Skip to content

Commit

Permalink
Address CR
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa committed Mar 3, 2022
1 parent f3ffbcb commit c1d6a39
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 133 deletions.
4 changes: 0 additions & 4 deletions api/types/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ func TestAppServerSorter(t *testing.T) {
for _, c := range cases {
c := c
t.Run(fmt.Sprintf("%s desc", c.name), func(t *testing.T) {
t.Parallel()

sortBy := SortBy{Field: c.fieldName, IsDesc: true}
servers := AppServers(makeServers(testValsUnordered, c.fieldName))
require.NoError(t, servers.SortByCustom(sortBy))
Expand All @@ -152,8 +150,6 @@ func TestAppServerSorter(t *testing.T) {
})

t.Run(fmt.Sprintf("%s asc", c.name), func(t *testing.T) {
t.Parallel()

sortBy := SortBy{Field: c.fieldName}
servers := AppServers(makeServers(testValsUnordered, c.fieldName))
require.NoError(t, servers.SortByCustom(sortBy))
Expand Down
9 changes: 8 additions & 1 deletion api/types/appserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,14 @@ func (s AppServers) Len() int { return len(s) }

// Less compares app servers by name and host ID.
func (s AppServers) Less(i, j int) bool {
return s[i].GetName() < s[j].GetName() && s[i].GetHostID() < s[j].GetHostID()
switch {
case s[i].GetName() < s[j].GetName():
return true
case s[i].GetName() > s[j].GetName():
return false
default:
return s[i].GetHostID() < s[j].GetHostID()
}
}

// Swap swaps two app servers.
Expand Down
9 changes: 8 additions & 1 deletion api/types/databaseserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,14 @@ func (s DatabaseServers) Len() int { return len(s) }

// Less compares database servers by name and host ID.
func (s DatabaseServers) Less(i, j int) bool {
return s[i].GetName() < s[j].GetName() && s[i].GetHostID() < s[j].GetHostID()
switch {
case s[i].GetName() < s[j].GetName():
return true
case s[i].GetName() > s[j].GetName():
return false
default:
return s[i].GetHostID() < s[j].GetHostID()
}
}

// Swap swaps two database servers.
Expand Down
4 changes: 0 additions & 4 deletions api/types/databaseserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ func TestDatabaseServerSorter(t *testing.T) {
for _, c := range cases {
c := c
t.Run(fmt.Sprintf("%s desc", c.name), func(t *testing.T) {
t.Parallel()

sortBy := SortBy{Field: c.fieldName, IsDesc: true}
servers := DatabaseServers(makeServers(testValsUnordered, c.fieldName))
require.NoError(t, servers.SortByCustom(sortBy))
Expand All @@ -165,8 +163,6 @@ func TestDatabaseServerSorter(t *testing.T) {
})

t.Run(fmt.Sprintf("%s asc", c.name), func(t *testing.T) {
t.Parallel()

sortBy := SortBy{Field: c.fieldName}
servers := DatabaseServers(makeServers(testValsUnordered, c.fieldName))
require.NoError(t, servers.SortByCustom(sortBy))
Expand Down
9 changes: 8 additions & 1 deletion api/types/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,14 @@ func (s WindowsDesktops) Len() int { return len(s) }

// Less compares desktops by name and host ID.
func (s WindowsDesktops) Less(i, j int) bool {
return s[i].GetName() < s[j].GetName() && s[i].GetHostID() < s[j].GetHostID()
switch {
case s[i].GetName() < s[j].GetName():
return true
case s[i].GetName() > s[j].GetName():
return false
default:
return s[i].GetHostID() < s[j].GetHostID()
}
}

// Swap swaps two windows desktops.
Expand Down
14 changes: 4 additions & 10 deletions api/types/desktop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ func TestWindowsDesktopsSorter(t *testing.T) {
for _, c := range cases {
c := c
t.Run(fmt.Sprintf("%s desc", c.name), func(t *testing.T) {
t.Parallel()

sortBy := SortBy{Field: c.fieldName, IsDesc: true}
servers := WindowsDesktops(makeDesktops(testValsUnordered, c.fieldName))
require.NoError(t, servers.SortByCustom(sortBy))
Expand All @@ -74,8 +72,6 @@ func TestWindowsDesktopsSorter(t *testing.T) {
})

t.Run(fmt.Sprintf("%s asc", c.name), func(t *testing.T) {
t.Parallel()

sortBy := SortBy{Field: c.fieldName}
servers := WindowsDesktops(makeDesktops(testValsUnordered, c.fieldName))
require.NoError(t, servers.SortByCustom(sortBy))
Expand All @@ -85,10 +81,8 @@ func TestWindowsDesktopsSorter(t *testing.T) {
})
}

t.Run("error", func(t *testing.T) {
t.Parallel()
sortBy := SortBy{Field: "unsupported"}
desktops := makeDesktops(testValsUnordered, "does-not-matter")
require.True(t, trace.IsNotImplemented(WindowsDesktops(desktops).SortByCustom(sortBy)))
})
// Test error.
sortBy := SortBy{Field: "unsupported"}
desktops := makeDesktops(testValsUnordered, "does-not-matter")
require.True(t, trace.IsNotImplemented(WindowsDesktops(desktops).SortByCustom(sortBy)))
}
4 changes: 0 additions & 4 deletions api/types/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ func TestServerSorter(t *testing.T) {
for _, c := range cases {
c := c
t.Run(fmt.Sprintf("%s desc", c.name), func(t *testing.T) {
t.Parallel()

sortBy := SortBy{Field: c.fieldName, IsDesc: true}
servers := Servers(makeServers(testValsUnordered, c.fieldName))
require.NoError(t, servers.SortByCustom(sortBy))
Expand All @@ -87,8 +85,6 @@ func TestServerSorter(t *testing.T) {
})

t.Run(fmt.Sprintf("%s asc", c.name), func(t *testing.T) {
t.Parallel()

sortBy := SortBy{Field: c.fieldName}
servers := Servers(makeServers(testValsUnordered, c.fieldName))
require.NoError(t, servers.SortByCustom(sortBy))
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ type Cache interface {

// ListResources returns a paginated list of resources.
ListResources(ctx context.Context, req proto.ListResourcesRequest) (*types.ListResourcesResponse, error)
// ListWindowsDesktops returns a paginated list of windows desktops..
// ListWindowsDesktops returns a paginated list of windows desktops.
ListWindowsDesktops(ctx context.Context, req types.ListWindowsDesktopsRequest) (*types.ListWindowsDesktopsResponse, error)
}

Expand Down
Loading

0 comments on commit c1d6a39

Please sign in to comment.