Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
console
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
console
Commits
84129f23
Commit
84129f23
authored
Apr 27, 2017
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试
parent
c1dccfb9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
2 deletions
+97
-2
package.json
package.json
+10
-2
test.ts
test.ts
+87
-0
No files found.
package.json
View file @
84129f23
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
"start"
:
"node server.js"
,
"start"
:
"node server.js"
,
"server"
:
"node server.js"
,
"server"
:
"node server.js"
,
"tsc"
:
"tsc"
,
"tsc"
:
"tsc"
,
"prestart"
:
"tsc"
"prestart"
:
"tsc"
,
"test"
:
"node test.js"
,
"pretest"
:
"tsc"
},
},
"dependencies"
:
{
"dependencies"
:
{
"
aliyun-oss-upload-stream
"
:
"
^1.3.0
"
,
"
aliyun-oss-upload-stream
"
:
"
^1.3.0
"
,
...
@@ -31,16 +33,22 @@
...
@@ -31,16 +33,22 @@
"
@types/bluebird
"
:
"
^3.5.0
"
,
"
@types/bluebird
"
:
"
^3.5.0
"
,
"
@types/busboy
"
:
"
^0.2.3
"
,
"
@types/busboy
"
:
"
^0.2.3
"
,
"
@types/fs-extra-promise
"
:
"
^0.0.32
"
,
"
@types/fs-extra-promise
"
:
"
^0.0.32
"
,
"
@types/isomorphic-fetch
"
:
"
0.0.34
"
,
"
@types/koa
"
:
"
^2.0.37
"
,
"
@types/koa
"
:
"
^2.0.37
"
,
"
@types/koa-bodyparser
"
:
"
^3.0.22
"
,
"
@types/koa-bodyparser
"
:
"
^3.0.22
"
,
"
@types/koa-router
"
:
"
^7.0.22
"
,
"
@types/koa-router
"
:
"
^7.0.22
"
,
"
@types/lodash
"
:
"
^4.14.63
"
,
"
@types/log4js
"
:
"
0.0.32
"
,
"
@types/log4js
"
:
"
0.0.32
"
,
"
@types/node
"
:
"
^7.0.13
"
,
"
@types/node
"
:
"
^7.0.13
"
,
"
@types/pluralize
"
:
"
0.0.27
"
,
"
@types/pluralize
"
:
"
0.0.27
"
,
"
@types/tmp
"
:
"
0.0.32
"
,
"
@types/tmp
"
:
"
0.0.32
"
,
"
@types/uuid
"
:
"
^2.0.29
"
,
"
@types/uuid
"
:
"
^2.0.29
"
,
"
@types/xmldoc
"
:
"
^0.5.0
"
,
"
isomorphic-fetch
"
:
"
latest
"
,
"
lodash
"
:
"
latest
"
,
"
nodemon
"
:
"
^1.11.0
"
,
"
nodemon
"
:
"
^1.11.0
"
,
"
tslint
"
:
"
^5.1.0
"
,
"
tslint
"
:
"
^5.1.0
"
,
"
typescript
"
:
"
^2.1.4
"
"
typescript
"
:
"
^2.1.4
"
,
"
xmldoc
"
:
"
^1.0.0
"
}
}
}
}
test.ts
0 → 100644
View file @
84129f23
/**
* Created by zh99998 on 2017/4/27.
*/
import
*
as
fetch
from
'
isomorphic-fetch
'
;
import
*
as
_
from
'
lodash
'
;
import
{
XmlDocument
}
from
'
xmldoc
'
;
// 配置
const
old_apps_json
=
'
https://api.moecube.com/apps.json
'
;
const
new_apps_json
=
'
http://114.215.243.95:8001/v2/apps
'
;
const
old_metalinks
=
(
package_id
)
=>
`https://cdn01.moecube.com/release/metalinks/
${
package_id
}
.meta4`
;
const
new_metalinks
=
(
package_id
)
=>
`https://cdn01.moecube.com/release/metalinks/
${
package_id
}
.meta4`
;
// 修改
const
old_checksums
=
(
package_id
)
=>
`https://cdn01.moecube.com/release/checksums/
${
package_id
}
`
;
const
new_checksums
=
(
package_id
)
=>
`https://cdn01.moecube.com/release/checksums/
${
package_id
}
`
;
// 修改
async
function
test_checksums
()
{
const
apps
:
any
[]
=
(
await
(
await
fetch
(
new_apps_json
)).
json
())
.
filter
(
i
=>
!
[
'
ygopro
'
,
'
desmume
'
].
includes
(
i
.
id
));
// 排除 ygopro 和 desmume
for
(
let
app
of
_
.
sampleSize
(
apps
,
5
))
{
console
.
log
(
`正在测试
${
app
.
id
}
的 checksum`
);
const
old_checksum
=
await
(
await
fetch
(
old_checksums
(
app
.
id
))).
text
();
const
new_checksum
=
await
(
await
fetch
(
new_checksums
(
app
.
id
))).
text
();
if
(
old_checksum
!==
new_checksum
)
{
console
.
log
(
'
旧
'
,
old_checksum
);
console
.
log
(
'
新
'
,
new_checksum
);
throw
`应用
${
app
.
id
}
的 checksum 不一致`
;
}
}
}
async
function
test_download
()
{
const
apps
:
any
[]
=
(
await
(
await
fetch
(
new_apps_json
)).
json
())
.
filter
(
i
=>
!
[
'
ygopro
'
,
'
desmume
'
].
includes
(
i
.
id
));
// 排除 ygopro 和 desmume
const
app
:
any
=
_
.
sample
(
apps
);
console
.
log
(
`正在测试
${
app
.
id
}
的 下载`
);
const
metalink
=
await
(
await
fetch
(
new_metalinks
(
app
.
id
))).
text
();
const
xml
=
new
XmlDocument
(
metalink
);
const
url
=
xml
.
valueWithPath
(
'
file.url
'
);
const
response
=
await
fetch
(
url
,
{
method
:
'
HEAD
'
});
if
(
!
response
.
ok
)
{
throw
`
${
app
.
id
}
的 下载地址
${
url
}
返回
${
response
.
statusText
}
`
;
}
}
async
function
test_update
()
{
// TODO
}
async
function
test_apps_json
()
{
const
old_apps
=
await
(
await
fetch
(
old_apps_json
)).
json
();
const
new_apps
=
await
(
await
fetch
(
new_apps_json
)).
json
();
for
(
let
new_app
of
new_apps
)
{
let
old_app
=
old_apps
.
find
(
i
=>
i
.
id
==
new_app
.
id
);
delete
old_app
.
network
;
delete
old_app
.
author
;
delete
new_app
.
author
;
if
(
!
old_app
)
{
throw
`应用
${
new_app
.
id
}
在旧的列表不存在`
;
}
for
(
let
[
key
,
value
]
of
Object
.
entries
(
old_app
))
{
if
(
!
new_app
[
key
])
{
throw
`应用
${
new_app
.
id
}
的
${
key
}
字段在的新的列表中不存在`
;
}
if
(
!
_
.
isEqual
(
new_app
[
key
],
value
))
{
console
.
log
(
'
旧
'
,
JSON
.
stringify
(
value
,
null
,
2
));
console
.
log
(
'
新
'
,
JSON
.
stringify
(
new_app
[
key
],
null
,
2
));
throw
`应用
${
new_app
.
id
}
的
${
key
}
字段跟旧的不同`
;
}
}
}
}
async
function
main
()
{
await
test_apps_json
();
await
test_checksums
();
await
test_download
();
await
test_update
();
console
.
log
(
'
ok
'
);
}
main
();
process
.
on
(
'
unhandledRejection
'
,
(
reason
,
p
)
=>
{
console
.
error
(
'
Unhandled Rejection at: Promise
'
,
p
,
'
reason:
'
,
reason
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment