Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mirera-db
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
mirera
mirera-db
Commits
4be6c83b
Commit
4be6c83b
authored
Oct 19, 2018
by
Никита Бесшапошников
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test for new mirera
parent
cd5fdfc0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
173 additions
and
0 deletions
+173
-0
index.js
index.js
+3
-0
solution.js
solution.js
+7
-0
test.js
test.js
+163
-0
No files found.
index.js
View file @
4be6c83b
...
...
@@ -62,6 +62,9 @@ module.exports = (connectionUri, relaxed) => {
module
.
exports
.
tasks
=
require
(
'
./task
'
);
mongoose
.
tasks
=
module
.
exports
.
tasks
;
module
.
exports
.
tests
=
require
(
'
./test
'
);
mongoose
.
tests
=
module
.
exports
.
tests
;
module
.
exports
.
groups
=
require
(
'
./group
'
);
mongoose
.
groups
=
module
.
exports
.
groups
;
...
...
solution.js
View file @
4be6c83b
...
...
@@ -137,6 +137,13 @@ module.exports.getSolutionWithFileInfo = (solutionId) => {
}))
}
if
(
solution
.
task
.
tests
)
{
promises
.
push
(
mongoose
.
tests
.
getTests
(
solution
.
task
.
tests
)
.
then
(
tests
=>
{
solution
.
task
.
tests
=
tests
.
map
(
t
=>
t
.
toObject
());
}))
}
return
Promise
.
all
(
promises
);
})
.
then
(()
=>
{
...
...
test.js
0 → 100644
View file @
4be6c83b
"
use strict
"
;
const
mongoose
=
require
(
"
mongoose
"
);
const
dbContests
=
require
(
'
./contest
'
);
const
dbTasks
=
require
(
'
./task
'
);
const
TestSchema
=
new
mongoose
.
Schema
({
inputType
:
{
type
:
String
,
required
:
true
},
inputProgramArgs
:
{
type
:
String
},
inputFiles
:
{
type
:
[
mongoose
.
Schema
.
Types
.
ObjectId
],
refs
:
'
fs
'
},
stdinFile
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
refs
:
'
fs
'
},
outputType
:
{
type
:
String
,
required
:
true
},
outputProgramArgs
:
{
type
:
String
},
outputFiles
:
{
type
:
[
mongoose
.
Schema
.
Types
.
ObjectId
],
refs
:
'
fs
'
},
stdoutFile
:
{
type
:
mongoose
.
Schema
.
Types
.
ObjectId
,
refs
:
'
fs
'
},
runArgs
:
{
type
:
String
},
exitCode
:
{
type
:
Number
,
}
});
const
Test
=
mongoose
.
connection
.
model
(
'
Test
'
,
TestSchema
);
module
.
exports
.
schema
=
TestSchema
;
module
.
exports
.
model
=
Test
;
module
.
exports
.
getTests
=
(
testIds
)
=>
{
return
Test
.
find
({
_id
:
{
$in
:
testIds
}});
};
module
.
exports
.
createTest
=
(
test
)
=>
{
return
new
Test
(
test
).
save
();
};
module
.
exports
.
updateTest
=
(
testId
,
test
)
=>
{
return
Test
.
findOneAndUpdate
({
_id
:
testId
},
test
);
};
module
.
exports
.
copyTestToTask
=
(
taskId
,
testIndex
)
=>
{
let
newTask
=
{};
return
dbTasks
.
model
.
findOne
({
_id
:
taskId
})
.
then
((
task
)
=>
{
newTask
=
task
;
return
Test
.
findOne
({
_id
:
task
.
tests
[
testIndex
]});
})
.
then
((
test
)
=>
{
test
=
test
.
toObject
();
test
.
_id
=
undefined
;
return
module
.
exports
.
createTest
(
test
);
})
.
then
((
newTest
)
=>
{
newTask
=
newTask
.
toObject
();
newTask
.
tests
.
push
(
newTest
.
_id
);
return
dbTasks
.
model
.
update
({
_id
:
taskId
},
newTask
);
});
};
module
.
exports
.
copyTestToContest
=
(
contestId
,
testIndex
)
=>
{
let
newContest
=
{};
return
dbContests
.
model
.
findOne
({
_id
:
contestId
})
.
then
((
contest
)
=>
{
newContest
=
contest
;
return
Test
.
findOne
({
_id
:
contest
.
tests
[
testIndex
]});
})
.
then
((
test
)
=>
{
test
=
test
.
toObject
();
test
.
_id
=
undefined
;
return
module
.
exports
.
createTest
(
test
);
})
.
then
((
newTest
)
=>
{
newContest
=
newContest
.
toObject
();
newContest
.
tests
.
push
(
newTest
.
_id
);
return
dbContests
.
model
.
update
({
_id
:
contestId
},
newContest
);
});
};
module
.
exports
.
addTestToTask
=
(
taskId
,
test
)
=>
{
return
module
.
exports
.
createTest
(
test
)
.
then
((
test
)
=>
{
return
dbTasks
.
model
.
findOneAndUpdate
({
_id
:
taskId
},
{
$push
:
{
tests
:
test
.
_id
}
});
});
};
module
.
exports
.
addTestToContest
=
(
contestId
,
test
)
=>
{
return
module
.
exports
.
createTest
(
test
)
.
then
((
test
)
=>
{
return
dbContests
.
model
.
findOneAndUpdate
({
_id
:
contestId
},
{
$push
:
{
tests
:
test
.
_id
}
});
});
};
module
.
exports
.
removeTestFromTask
=
(
taskId
,
testIndex
)
=>
{
let
deleteTestId
=
{};
return
dbTasks
.
model
.
findOne
({
_id
:
taskId
})
.
then
((
task
)
=>
{
let
newTask
=
task
.
toObject
();
deleteTestId
=
newTask
.
tests
[
testIndex
];
newTask
.
tests
.
splice
(
testIndex
,
1
);
return
dbTasks
.
model
.
update
({
_id
:
taskId
},
newTask
);
})
.
then
(()
=>
{
return
Test
.
remove
({
_id
:
deleteTestId
});
});
};
module
.
exports
.
removeTestFromContest
=
(
contestId
,
testIndex
)
=>
{
let
deleteTestId
=
{};
return
dbContests
.
model
.
findOne
({
_id
:
contestId
})
.
then
((
contest
)
=>
{
let
newContest
=
contest
.
toObject
();
deleteTestId
=
newContest
.
tests
[
testIndex
];
newContest
.
tests
.
splice
(
testIndex
,
1
);
return
dbContests
.
model
.
update
({
_id
:
contestId
},
newContest
);
})
.
then
(()
=>
{
return
Test
.
remove
({
_id
:
deleteTestId
});
});
};
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