mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
@ -4,6 +4,7 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
@ -79,6 +80,9 @@ func (api *API) workspaceResource(rw http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
apiAgents = append(apiAgents, convertedAgent)
|
||||
}
|
||||
sort.Slice(apiAgents, func(i, j int) bool {
|
||||
return apiAgents[i].Name < apiAgents[j].Name
|
||||
})
|
||||
|
||||
metadata, err := api.Database.GetWorkspaceResourceMetadataByResourceID(r.Context(), workspaceResource.ID)
|
||||
if err != nil {
|
||||
|
@ -28,6 +28,11 @@ func TestWorkspaceResource(t *testing.T) {
|
||||
Type: "example",
|
||||
Agents: []*proto.Agent{{
|
||||
Id: "something",
|
||||
Name: "b",
|
||||
Auth: &proto.Agent_Token{},
|
||||
}, {
|
||||
Id: "another",
|
||||
Name: "a",
|
||||
Auth: &proto.Agent_Token{},
|
||||
}},
|
||||
}},
|
||||
@ -41,8 +46,12 @@ func TestWorkspaceResource(t *testing.T) {
|
||||
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
|
||||
resources, err := client.WorkspaceResourcesByBuild(context.Background(), workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
_, err = client.WorkspaceResource(context.Background(), resources[0].ID)
|
||||
resource, err := client.WorkspaceResource(context.Background(), resources[0].ID)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, resource.Agents, 2)
|
||||
// Ensure it's sorted alphabetically!
|
||||
require.Equal(t, "a", resource.Agents[0].Name)
|
||||
require.Equal(t, "b", resource.Agents[1].Name)
|
||||
})
|
||||
|
||||
t.Run("Apps", func(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user