Skip to content

Commit fa48280

Browse files
committed
refactor(utils): remove mixin utilities and update test imports
Removed the mixin utility functions and related type definitions from the codebase. Updated test file to remove mixin-related imports and tests, and improved code formatting in data API tests. 移除混入实用程序并更新测试导入 从代码库中删除了混入实用函数和相关类型定义。更新测试文件以 移除混入相关的导入和测试,并改进了数据 API 测试中的代码格式。 Change-Id: I6cba222f10ad5e040b200bfaeea254bb09b44782 Signed-off-by: OhYee <oyohyee@oyohyee.com>
1 parent fec848c commit fa48280

3 files changed

Lines changed: 28 additions & 73 deletions

File tree

src/utils/mixin.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/utils/mixmin.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/unittests/utils.test.ts

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
import { Config } from '../../src/utils/config';
2+
import { DataAPI, ResourceType } from '../../src/utils/data-api';
23
import {
3-
AgentRunError,
44
HTTPError,
5-
ResourceNotExistError,
65
ResourceAlreadyExistError,
7-
ClientError,
6+
ResourceNotExistError,
87
} from '../../src/utils/exception';
9-
import * as model from '../../src/utils/model';
10-
import { mixin } from '../../src/utils/mixin';
118
import {
12-
updateObjectProperties,
139
listAllResourcesFunction,
14-
ResourceBase,
10+
updateObjectProperties,
1511
} from '../../src/utils/resource';
16-
import { DataAPI, ResourceType } from '../../src/utils/data-api';
1712

1813
describe('utils - config', () => {
1914
test('config defaults and data/control/devs endpoints and accountId error', () => {
@@ -59,25 +54,6 @@ describe('utils - exception', () => {
5954
});
6055
});
6156

62-
63-
describe('utils - mixin', () => {
64-
test('mixin copies prototype and static properties', () => {
65-
class A {
66-
static staticA = 1;
67-
protoA() { return 'a'; }
68-
}
69-
70-
class B { }
71-
72-
const Mixed = mixin(A as any, B as any) as any;
73-
// static prop copied
74-
expect(Mixed.staticA).toBe(1);
75-
// prototype method available
76-
const inst = new Mixed();
77-
expect(typeof inst.protoA).toBe('function');
78-
});
79-
});
80-
8157
describe('utils - resource helpers', () => {
8258
test('updateObjectProperties only copies data fields', () => {
8359
const target: any = {};
@@ -91,8 +67,13 @@ describe('utils - resource helpers', () => {
9167
test('listAllResourcesFunction paginates and dedups', async () => {
9268
// listAllResourcesFunction uses a pageSize of 50 internally.
9369
// To exercise pagination we return 50 items on first call and a small last page on second.
94-
const firstPage = Array.from({ length: 50 }, (_, i) => ({ uniqIdCallback: () => `${i + 1}` }));
95-
const secondPage = [{ uniqIdCallback: () => '50' }, { uniqIdCallback: () => '51' }];
70+
const firstPage = Array.from({ length: 50 }, (_, i) => ({
71+
uniqIdCallback: () => `${i + 1}`,
72+
}));
73+
const secondPage = [
74+
{ uniqIdCallback: () => '50' },
75+
{ uniqIdCallback: () => '51' },
76+
];
9677
const pages = [firstPage, secondPage];
9778
let called = 0;
9879
const list = async (params?: any) => {
@@ -120,14 +101,29 @@ describe('utils - data-api small surface', () => {
120101
const cfg = new Config({ token: 'tok', accountId: 'acct' });
121102
const d = new DataAPI('name', ResourceType.Runtime, cfg, 'ns') as any;
122103

123-
const r1 = await d.prepareRequest('POST', 'https://example.com/x', { a: 1 }, { H: 'v' });
104+
const r1 = await d.prepareRequest(
105+
'POST',
106+
'https://example.com/x',
107+
{ a: 1 },
108+
{ H: 'v' }
109+
);
124110
expect(r1.body).toBeDefined();
125111
expect(r1.headers['Agentrun-Access-Token']).toBe('tok');
126112

127-
const r2 = await d.prepareRequest('PUT', 'https://example.com/x', Buffer.from('hi'), {});
113+
const r2 = await d.prepareRequest(
114+
'PUT',
115+
'https://example.com/x',
116+
Buffer.from('hi'),
117+
{}
118+
);
128119
expect(Buffer.isBuffer(r2.body)).toBe(true);
129120

130-
const r3 = await d.prepareRequest('PATCH', 'https://example.com/x', 'rawtext', {});
121+
const r3 = await d.prepareRequest(
122+
'PATCH',
123+
'https://example.com/x',
124+
'rawtext',
125+
{}
126+
);
131127
expect(r3.body).toBe('rawtext');
132128
});
133129
});

0 commit comments

Comments
 (0)