mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add tests for app ID copy in app healths (#12088)
This commit is contained in:
@@ -226,7 +226,12 @@ type PostAppHealthsRequest struct {
|
||||
Healths map[uuid.UUID]codersdk.WorkspaceAppHealth
|
||||
}
|
||||
|
||||
func AppHealthPoster(aAPI proto.DRPCAgentClient) func(ctx context.Context, req PostAppHealthsRequest) error {
|
||||
// BatchUpdateAppHealthsClient is a partial interface of proto.DRPCAgentClient.
|
||||
type BatchUpdateAppHealthsClient interface {
|
||||
BatchUpdateAppHealths(ctx context.Context, req *proto.BatchUpdateAppHealthRequest) (*proto.BatchUpdateAppHealthResponse, error)
|
||||
}
|
||||
|
||||
func AppHealthPoster(aAPI BatchUpdateAppHealthsClient) func(ctx context.Context, req PostAppHealthsRequest) error {
|
||||
return func(ctx context.Context, req PostAppHealthsRequest) error {
|
||||
pReq, err := ProtoFromAppHealthsRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -287,6 +287,8 @@ func ProtoFromAppHealthsRequest(req PostAppHealthsRequest) (*proto.BatchUpdateAp
|
||||
return nil, xerrors.Errorf("unknown app health: %s", h)
|
||||
}
|
||||
|
||||
// Copy the ID, otherwise all updates will have the same ID (the last
|
||||
// one in the list).
|
||||
var idCopy uuid.UUID
|
||||
copy(idCopy[:], id[:])
|
||||
pReq.Updates = append(pReq.Updates, &proto.BatchUpdateAppHealthRequest_HealthUpdate{
|
||||
|
||||
Reference in New Issue
Block a user