feat(appstore): use shared resolver
This commit is contained in:
@@ -2,12 +2,14 @@ import { assertEquals, assertThrows } from '@std/assert';
|
||||
|
||||
import { AppStoreManager } from '../ts/classes/appstore.ts';
|
||||
import { OneboxDockerManager } from '../ts/classes/docker.ts';
|
||||
import type { IAppVersionConfig } from '../ts/classes/appstore-types.ts';
|
||||
import type * as servezoneInterfaces from '@serve.zone/interfaces';
|
||||
import type { IService } from '../ts/types.ts';
|
||||
|
||||
type IAppStoreVersionConfig = servezoneInterfaces.appstore.IAppStoreVersionConfig;
|
||||
|
||||
const createAppStore = () => new AppStoreManager({} as any);
|
||||
|
||||
const baseConfig: IAppVersionConfig = {
|
||||
const baseConfig: IAppStoreVersionConfig = {
|
||||
image: 'example/app:1.0.0',
|
||||
port: 3000,
|
||||
envVars: [
|
||||
@@ -82,19 +84,19 @@ Deno.test('appstore rejects invalid template ports and volumes', () => {
|
||||
});
|
||||
|
||||
Deno.test('appstore resolves repo manifests and docker digest-tracked latest images', async () => {
|
||||
const catalogBaseUrl = 'https://catalog.example.test';
|
||||
const manifestUrl = 'https://code.example.test/cloudly/servezone.catalog.json';
|
||||
const appStoreBaseUrl = 'https://appstore.example.test';
|
||||
const manifestUrl = 'https://code.example.test/cloudly/servezone.appstore.json';
|
||||
const digest = 'sha256:1234567890abcdef';
|
||||
|
||||
const fakeFetch: typeof fetch = async (input, init) => {
|
||||
const url = input instanceof Request ? input.url : input.toString();
|
||||
const method = init?.method || 'GET';
|
||||
|
||||
if (url === `${catalogBaseUrl}/catalog.resolved.json`) {
|
||||
if (url === `${appStoreBaseUrl}/appstore.resolved.json`) {
|
||||
return new Response('not found', { status: 404 });
|
||||
}
|
||||
|
||||
if (url === `${catalogBaseUrl}/catalog.json`) {
|
||||
if (url === `${appStoreBaseUrl}/appstore.json`) {
|
||||
return Response.json({
|
||||
schemaVersion: 1,
|
||||
updatedAt: '2026-05-24T00:00:00Z',
|
||||
@@ -152,14 +154,14 @@ Deno.test('appstore resolves repo manifests and docker digest-tracked latest ima
|
||||
};
|
||||
|
||||
const appStore = new AppStoreManager({} as any, {
|
||||
repoBaseUrl: catalogBaseUrl,
|
||||
baseUrl: appStoreBaseUrl,
|
||||
fetch: fakeFetch,
|
||||
});
|
||||
|
||||
const catalog = await appStore.getCatalog();
|
||||
assertEquals(catalog.apps[0].latestVersion, `latest@${digest}`);
|
||||
assertEquals(catalog.apps[0].resolvedSource?.manifestHash?.length, 64);
|
||||
assertEquals(catalog.apps[0].upgradeStrategy, 'dockerDigest');
|
||||
const appStoreIndex = await appStore.getAppStore();
|
||||
assertEquals(appStoreIndex.apps[0].latestVersion, `latest@${digest}`);
|
||||
assertEquals(appStoreIndex.apps[0].resolvedSource?.manifestHash?.length, 64);
|
||||
assertEquals(appStoreIndex.apps[0].upgradeStrategy, 'dockerDigest');
|
||||
|
||||
const appMeta = await appStore.getAppMeta('cloudly');
|
||||
assertEquals(appMeta.latestVersion, `latest@${digest}`);
|
||||
@@ -167,7 +169,7 @@ Deno.test('appstore resolves repo manifests and docker digest-tracked latest ima
|
||||
|
||||
const config = await appStore.getAppVersionConfig('cloudly', appMeta.latestVersion);
|
||||
assertEquals(config.image, 'registry.example.test/serve.zone/cloudly:latest');
|
||||
assertEquals(config.catalogVersion, `latest@${digest}`);
|
||||
assertEquals(config.appStoreVersion, `latest@${digest}`);
|
||||
assertEquals(config.resolvedImageDigest, digest);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user