Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanahiro committed Sep 8, 2024
1 parent 76ab80f commit 2b00d6f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/test.benchmark.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "chiitiler",
"version": "1.12.7",
"version": "1.13.0",
"description": "Tiny map rendering server for MapLibre Style Spec",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
25 changes: 25 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { describe, it, expect } from 'vitest';

import {
getRenderedBboxBuffer,
getRenderedBboxStream,
getRenderedTileBuffer,
getRenderedTileStream,
ChiitilerCache,
} from './index.js';

describe('library mode', () => {
// testing actual behavior of rendering methods is difficult...
it('members are exported', async () => {
expect(getRenderedBboxBuffer).toBeDefined();
expect(getRenderedBboxStream).toBeDefined();
expect(getRenderedTileBuffer).toBeDefined();
expect(getRenderedTileStream).toBeDefined();

// actual behaviors are tested in cache module
expect(ChiitilerCache.fileCache).toBeDefined();
expect(ChiitilerCache.memoryCache).toBeDefined();
expect(ChiitilerCache.noneCache).toBeDefined();
expect(ChiitilerCache.s3Cache).toBeDefined();
});
});
4 changes: 4 additions & 0 deletions src/server/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('initServer', () => {
port: 8989,
cache: cache.noneCache(),
debug: false,
stream: false,
});
const res = await app.request('/health');
expect(res.status).toBe(200);
Expand All @@ -28,6 +29,7 @@ describe('initServer', () => {
port: 8989,
cache: cache.noneCache(),
debug: true,
stream: false,
});
const res = await app.request('/health');
expect(res.status).toBe(200);
Expand All @@ -45,6 +47,7 @@ describe('initServer', () => {
port: 8989,
cache: cache.noneCache(),
debug: false,
stream: false,
});

const res = await app.request('/tiles/0/0/0.png');
Expand All @@ -71,6 +74,7 @@ describe('initServer', () => {
port: 8989,
cache: cache.noneCache(),
debug: false,
stream: false,
});

const res = await app.request('/clip.png?bbox=0,1,2,3');
Expand Down
6 changes: 6 additions & 0 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ function initServer(options: InitServerOptions): InitializedServer {
const quality = Number(c.req.query('quality') ?? 100);
const margin = Number(c.req.query('margin') ?? 0);

c.header('Content-Type', `image/${ext}`);

try {
const sharp = await getRenderedTile({
stylejson: style,
Expand Down Expand Up @@ -162,6 +164,8 @@ function initServer(options: InitServerOptions): InitializedServer {
const quality = Number(c.req.query('quality') ?? 100);
const size = Number(c.req.query('size') ?? 1024);

c.header('Content-Type', `image/${ext}`);

try {
const sharp = await getRenderedBbox({
stylejson: url,
Expand Down Expand Up @@ -209,6 +213,8 @@ function initServer(options: InitServerOptions): InitializedServer {
const quality = Number(c.req.query('quality') ?? 100);
const size = Number(c.req.query('size') ?? 1024);

c.header('Content-Type', `image/${ext}`);

try {
const sharp = await getRenderedBbox({
stylejson: style,
Expand Down

0 comments on commit 2b00d6f

Please sign in to comment.