feat: add downloadable release management for desktop client
- Extend DesktopClientReleaseCheckResponse with platform, arch, and channel fields. - Introduce DesktopClientDownloadableRelease and DesktopClientDownloadableReleaseListResponse interfaces for managing downloadable releases. - Implement ListDownloadable method in DesktopClientReleaseService to retrieve downloadable releases based on the specified channel. - Update DesktopClientReleaseCheckResult to include platform, arch, and channel information. - Add resolveInstallerDownloadURL method to handle download URL resolution for releases. - Create new endpoint in DesktopReleaseHandler for listing downloadable releases. - Update router to include the new downloadable releases route. - Enhance tests to cover the new functionality for resolving download URLs and listing downloadable releases.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -192,3 +194,56 @@ func TestBuildDesktopClientReleaseObjectKeyReusesContentAddress(t *testing.T) {
|
||||
require.Equal(t, first, second)
|
||||
require.Equal(t, "desktop-client/releases/blobs/"+sum+".exe", first)
|
||||
}
|
||||
|
||||
func TestResolveDownloadURLResultUsesSignedDownloadURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
objectKey := "desktop-client/releases/blobs/client.zip"
|
||||
storage := &desktopReleaseDownloadURLStorage{}
|
||||
svc := &DesktopClientReleaseService{storage: storage}
|
||||
|
||||
result, err := svc.resolveDownloadURLResult(&domain.DesktopClientRelease{
|
||||
DownloadSource: DesktopClientDownloadSourceOSS,
|
||||
OSSObjectKey: &objectKey,
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "https://oss.example.test/signed/client.zip?Expires=123", result.DownloadURL)
|
||||
require.Equal(t, []string{objectKey}, storage.downloadURLCalls)
|
||||
require.Empty(t, storage.publicURLCalls)
|
||||
}
|
||||
|
||||
type desktopReleaseDownloadURLStorage struct {
|
||||
publicURLCalls []string
|
||||
downloadURLCalls []string
|
||||
}
|
||||
|
||||
func (s *desktopReleaseDownloadURLStorage) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *desktopReleaseDownloadURLStorage) PutBytes(context.Context, string, []byte, string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *desktopReleaseDownloadURLStorage) GetBytes(context.Context, string) ([]byte, error) {
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
func (s *desktopReleaseDownloadURLStorage) Exists(context.Context, string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (s *desktopReleaseDownloadURLStorage) Delete(context.Context, string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *desktopReleaseDownloadURLStorage) PublicURL(objectKey string) (string, error) {
|
||||
s.publicURLCalls = append(s.publicURLCalls, objectKey)
|
||||
return "", errors.New("public url should not be used for private release downloads")
|
||||
}
|
||||
|
||||
func (s *desktopReleaseDownloadURLStorage) DownloadURL(objectKey string) (string, error) {
|
||||
s.downloadURLCalls = append(s.downloadURLCalls, objectKey)
|
||||
return "https://oss.example.test/signed/client.zip?Expires=123", nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user