Skip to content
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
2 changes: 1 addition & 1 deletion components/public-api-server/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestPublicAPIServer_v1_WorkspaceService(t *testing.T) {
workspaceClient := v1.NewWorkspacesServiceClient(conn)

_, err = workspaceClient.GetWorkspace(ctx, &v1.GetWorkspaceRequest{})
requireErrorStatusCode(t, codes.Unimplemented, err)
require.NoError(t, err)

_, err = workspaceClient.ListWorkspaces(ctx, &v1.ListWorkspacesRequest{})
requireErrorStatusCode(t, codes.Unimplemented, err)
Expand Down
3 changes: 2 additions & 1 deletion components/public-api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"github.com/gitpod-io/gitpod/common-go/baseserver"
"github.com/gitpod-io/gitpod/common-go/log"
"github.com/gitpod-io/gitpod/public-api-server/pkg/apiv1"
v1 "github.com/gitpod-io/gitpod/public-api/v1"
"net/http"
)
Expand Down Expand Up @@ -36,7 +37,7 @@ func register(srv *baseserver.Server) error {
_, _ = w.Write([]byte(`hello world`))
})

v1.RegisterWorkspacesServiceServer(srv.GRPC(), v1.UnimplementedWorkspacesServiceServer{})
v1.RegisterWorkspacesServiceServer(srv.GRPC(), apiv1.NewWorkspaceService())
v1.RegisterPrebuildsServiceServer(srv.GRPC(), v1.UnimplementedPrebuildsServiceServer{})

return nil
Expand Down
36 changes: 36 additions & 0 deletions components/public-api-server/pkg/apiv1/workspace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package apiv1

import (
"context"
v1 "github.com/gitpod-io/gitpod/public-api/v1"
)

func NewWorkspaceService() *WorkspaceService {
return &WorkspaceService{
UnimplementedWorkspacesServiceServer: &v1.UnimplementedWorkspacesServiceServer{},
}
}

type WorkspaceService struct {
*v1.UnimplementedWorkspacesServiceServer
}

func (w *WorkspaceService) GetWorkspace(ctx context.Context, r *v1.GetWorkspaceRequest) (*v1.GetWorkspaceResponse, error) {
return &v1.GetWorkspaceResponse{
ResponseStatus: nil,
Result: &v1.Workspace{
WorkspaceId: r.GetWorkspaceId(),
OwnerId: "mock_owner",
ProjectId: "mock_project_id",
Context: &v1.WorkspaceContext{
ContextUrl: "https://github.com/gitpod-io/gitpod",
Details: nil,
},
Description: "This is a mock response",
},
}, nil
}
35 changes: 35 additions & 0 deletions components/public-api-server/pkg/apiv1/workspace_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package apiv1

import (
"context"
v1 "github.com/gitpod-io/gitpod/public-api/v1"
"github.com/stretchr/testify/require"
"testing"
)

func TestWorkspaceService_GetWorkspace(t *testing.T) {
svc := NewWorkspaceService()

workspaceID := "some-workspace-id"
resp, err := svc.GetWorkspace(context.Background(), &v1.GetWorkspaceRequest{
WorkspaceId: workspaceID,
})
require.NoError(t, err)
require.Equal(t, &v1.GetWorkspaceResponse{
ResponseStatus: nil,
Result: &v1.Workspace{
WorkspaceId: workspaceID,
OwnerId: "mock_owner",
ProjectId: "mock_project_id",
Context: &v1.WorkspaceContext{
ContextUrl: "https://github.com/gitpod-io/gitpod",
Details: nil,
},
Description: "This is a mock response",
},
}, resp)
}