Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simcaq-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simcaq
simcaq-node
Commits
35e17fd7
There was a problem fetching the pipeline summary.
Commit
35e17fd7
authored
8 years ago
by
Rudolf Copi Eckelberg
Browse files
Options
Downloads
Patches
Plain Diff
Simulation test coverage increase
parent
006998b2
No related branches found
No related tags found
2 merge requests
!116
Release v1.0.0
,
!25
Auth
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/routes/simulation.js
+1
-1
1 addition, 1 deletion
src/libs/routes/simulation.js
src/test/test.js
+76
-0
76 additions, 0 deletions
src/test/test.js
with
77 additions
and
1 deletion
src/libs/routes/simulation.js
+
1
−
1
View file @
35e17fd7
...
...
@@ -64,7 +64,7 @@ simulationApp.get('/:id', (req, res) => {
});
simulationApp
.
post
(
'
/:id
'
,
(
req
,
res
,
next
)
=>
{
if
(
!
req
.
body
)
{
if
(
!
Object
.
keys
(
req
.
body
).
length
)
{
res
.
send
({
success
:
false
,
msg
:
'
No field informed to update
'
});
}
else
{
next
();
...
...
This diff is collapsed.
Click to expand it.
src/test/test.js
+
76
−
0
View file @
35e17fd7
...
...
@@ -492,6 +492,7 @@ describe('Requires a simulation', () => {
Simulation
.
findById
(
res
.
body
.
id
,
(
err
,
simulation
)
=>
{
simulation
.
should
.
have
.
property
(
'
name
'
);
simulation
.
name
.
should
.
be
.
a
(
'
string
'
);
simulation
.
name
.
should
.
equal
(
'
test
'
);
simulation
.
should
.
have
.
property
(
'
location
'
);
simulation
.
location
.
should
.
be
.
a
(
'
number
'
);
simulation
.
location
.
should
.
equal
(
5
);
...
...
@@ -500,6 +501,63 @@ describe('Requires a simulation', () => {
});
});
});
it
(
'
should update multiple fields on a single request
'
,
(
done
)
=>
{
newSimulation
=
new
Simulation
();
newSimulation
.
name
=
'
test
'
;
newSimulation
.
save
((
err
,
sim
)
=>
{
let
id
=
sim
.
_id
;
chai
.
request
(
server
)
.
post
(
`/api/v1/simulation/
${
id
}
`
)
.
send
({
location
:
5
,
time
:
3
,
failure_rate
:
[
0.1
,
0.2
,
0.3
],
goals_care
:
[
0.3
,
0.2
,
0.1
],
goals_inclusion
:
[
0.8
,
0.9
,
1
]
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
id
'
);
res
.
body
.
id
.
should
.
be
.
a
(
'
string
'
);
Simulation
.
findById
(
res
.
body
.
id
,
(
err
,
simulation
)
=>
{
simulation
.
should
.
have
.
property
(
'
name
'
);
simulation
.
name
.
should
.
be
.
a
(
'
string
'
);
simulation
.
name
.
should
.
equal
(
'
test
'
);
simulation
.
should
.
have
.
property
(
'
location
'
);
simulation
.
location
.
should
.
be
.
a
(
'
number
'
);
simulation
.
location
.
should
.
equal
(
5
);
simulation
.
should
.
have
.
property
(
'
time
'
);
simulation
.
time
.
should
.
be
.
a
(
'
number
'
);
simulation
.
time
.
should
.
equal
(
3
);
simulation
.
should
.
have
.
property
(
'
failure_rate
'
);
simulation
.
failure_rate
.
should
.
be
.
a
(
'
array
'
);
simulation
.
failure_rate
.
length
.
should
.
equal
(
3
);
simulation
.
should
.
have
.
property
(
'
goals_care
'
);
simulation
.
goals_care
.
should
.
be
.
a
(
'
array
'
);
simulation
.
goals_care
.
length
.
should
.
equal
(
3
);
simulation
.
should
.
have
.
property
(
'
goals_inclusion
'
);
simulation
.
goals_inclusion
.
should
.
be
.
a
(
'
array
'
);
simulation
.
goals_inclusion
.
length
.
should
.
equal
(
3
);
});
done
();
});
});
});
it
(
'
should not update an unexisting simulation
'
,
(
done
)
=>
{
newSimulation
=
new
Simulation
();
let
id
=
newSimulation
.
_id
;
chai
.
request
(
server
)
.
post
(
`/api/v1/simulation/
${
id
}
`
)
.
send
({
location
:
5
})
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
done
();
});
});
it
(
'
should update an existing simulation
\'
s time
'
,
(
done
)
=>
{
newSimulation
=
new
Simulation
();
newSimulation
.
name
=
'
test
'
;
...
...
@@ -524,4 +582,22 @@ describe('Requires a simulation', () => {
});
});
});
it
(
'
should not change results for empty post requests
'
,
(
done
)
=>
{
newSimulation
=
new
Simulation
();
newSimulation
.
name
=
'
test
'
;
newSimulation
.
save
((
err
,
sim
)
=>
{
let
id
=
sim
.
_id
;
chai
.
request
(
server
)
.
post
(
`/api/v1/simulation/
${
id
}
`
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
res
.
should
.
be
.
json
;
res
.
body
.
should
.
have
.
property
(
'
success
'
);
res
.
body
.
success
.
should
.
equal
(
false
);
done
();
});
});
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment