Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
blendb
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
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
C3SL
blendb
Commits
5a23cb47
There was a problem fetching the pipeline summary.
Commit
5a23cb47
authored
8 years ago
by
Lucas Fernandes de Oliveira
Browse files
Options
Downloads
Plain Diff
Merge branch 'issue/13' into 'master'
Issue
#13
: Fix engine tests See merge request
!8
parents
2e0797f1
62e71465
No related branches found
No related tags found
1 merge request
!8
Issue #13: Fix engine tests
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/engine.spec.ts
+30
-21
30 additions, 21 deletions
src/core/engine.spec.ts
src/core/engine.ts
+4
-2
4 additions, 2 deletions
src/core/engine.ts
with
34 additions
and
23 deletions
src/core/engine.spec.ts
+
30
−
21
View file @
5a23cb47
...
@@ -94,7 +94,6 @@ describe("engine class", () => {
...
@@ -94,7 +94,6 @@ describe("engine class", () => {
new
View
({
metrics
:
[
met3
,
met4
,
met7
],
dimensions
:
[
dim4
,
dim5
]}),
new
View
({
metrics
:
[
met3
,
met4
,
met7
],
dimensions
:
[
dim4
,
dim5
]}),
new
View
({
metrics
:
[
met6
,
met7
],
dimensions
:
[
dim3
,
dim4
,
dim5
,
dim6
]}),
new
View
({
metrics
:
[
met6
,
met7
],
dimensions
:
[
dim3
,
dim4
,
dim5
,
dim6
]}),
new
View
({
metrics
:
[
met8
,
met2
,
met3
],
dimensions
:
[
dim1
,
dim2
,
dim7
]}),
new
View
({
metrics
:
[
met8
,
met2
,
met3
],
dimensions
:
[
dim1
,
dim2
,
dim7
]}),
new
View
({
metrics
:
[
met1
,
met2
,
met3
],
dimensions
:
[
dim1
,
dim2
]}),
new
View
({
metrics
:
[
met2
,
met4
],
dimensions
:
[
dim1
,
dim2
]}),
new
View
({
metrics
:
[
met2
,
met4
],
dimensions
:
[
dim1
,
dim2
]}),
new
View
({
metrics
:
[
met8
],
dimensions
:
[
dim8
,
dim9
,
dim10
]}),
new
View
({
metrics
:
[
met8
],
dimensions
:
[
dim8
,
dim9
,
dim10
]}),
new
View
({
metrics
:
[
met9
],
dimensions
:
[
dim8
,
dim9
,
dim10
]}),
new
View
({
metrics
:
[
met9
],
dimensions
:
[
dim8
,
dim9
,
dim10
]}),
...
@@ -148,18 +147,19 @@ describe("engine class", () => {
...
@@ -148,18 +147,19 @@ describe("engine class", () => {
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
.
length
===
10
);
expect
(
optimalView
.
metrics
).
to
.
have
.
length
(
10
);
expect
(
optimalView
.
dimensions
.
length
===
10
);
expect
(
optimalView
.
dimensions
).
to
.
have
.
length
(
10
);
expect
(
optimalView
.
childViews
.
length
===
4
);
expect
(
optimalView
.
childViews
).
to
.
have
.
length
(
4
);
let
metAux
:
number
[]
=
optimalView
.
metrics
.
sort
().
map
((
met
:
Metric
)
=>
{
let
metAux
:
number
[]
=
optimalView
.
metrics
.
sort
().
map
((
met
:
Metric
)
=>
{
return
Number
(
met
.
name
.
split
(
"
:
"
)[
1
]);
return
Number
(
met
.
name
.
split
(
"
:
"
)[
1
]);
});
});
let
dimAux
:
number
[]
=
optimalView
.
dimensions
.
sort
().
map
((
dim
:
Dimension
)
=>
{
let
dimAux
:
number
[]
=
optimalView
.
dimensions
.
sort
().
map
((
dim
:
Dimension
)
=>
{
return
Number
(
dim
.
name
.
split
(
"
:
"
)[
1
]);
return
Number
(
dim
.
name
.
split
(
"
:
"
)[
1
]);
});
});
for
(
let
i
:
number
=
1
;
i
<=
10
;
++
i
)
{
expect
(
dimAux
[
i
]
===
i
);
for
(
let
i
:
number
=
0
;
i
<
10
;
++
i
)
{
expect
(
metAux
[
i
]
===
i
);
expect
(
dimAux
[
i
]).
to
.
be
.
equal
(
i
+
1
);
expect
(
metAux
[
i
]).
to
.
be
.
equal
(
i
+
1
);
}
}
});
});
it
(
"
should throw an exception, query with non-existent metric
"
,
()
=>
{
it
(
"
should throw an exception, query with non-existent metric
"
,
()
=>
{
...
@@ -201,11 +201,11 @@ describe("engine class", () => {
...
@@ -201,11 +201,11 @@ describe("engine class", () => {
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
.
length
===
3
);
expect
(
optimalView
.
metrics
).
to
.
have
.
length
(
3
);
expect
(
optimalView
.
dimensions
.
length
===
2
);
expect
(
optimalView
.
dimensions
).
to
.
have
.
length
(
2
);
expect
(
optimalView
.
childViews
.
length
===
0
);
expect
(
optimalView
.
childViews
).
to
.
have
.
length
(
0
);
expect
(
optimalView
.
id
===
views
[
0
].
id
);
expect
(
optimalView
.
id
).
to
.
be
.
equal
(
views
[
0
].
id
);
});
});
it
(
"
should be create a fill that cover the query, using sub dimensions
"
,
()
=>
{
it
(
"
should be create a fill that cover the query, using sub dimensions
"
,
()
=>
{
...
@@ -222,12 +222,16 @@ describe("engine class", () => {
...
@@ -222,12 +222,16 @@ describe("engine class", () => {
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
.
length
===
0
);
expect
(
optimalView
.
metrics
).
to
.
have
.
length
(
0
);
expect
(
optimalView
.
dimensions
.
length
===
2
);
expect
(
optimalView
.
dimensions
).
to
.
have
.
length
(
2
);
expect
(
optimalView
.
childViews
.
length
===
1
);
expect
(
optimalView
.
childViews
).
to
.
have
.
length
(
1
);
expect
(
optimalView
.
childViews
[
0
].
dimensions
.
some
((
item
)
=>
item
.
name
===
subdim1
.
name
));
expect
(
optimalView
).
satisfy
((
optView
:
View
)
=>
{
expect
(
optimalView
.
childViews
[
0
].
dimensions
.
some
((
item
)
=>
item
.
name
===
subdim2
.
name
));
return
optView
.
childViews
[
0
].
dimensions
.
some
((
item
)
=>
item
.
name
===
subdim1
.
name
);
});
expect
(
optimalView
).
satisfy
((
optView
:
View
)
=>
{
return
optView
.
childViews
[
0
].
dimensions
.
some
((
item
)
=>
item
.
name
===
subdim1
.
name
);
});
});
});
it
(
"
should be create a fill that cover the query, using the parents of sub dimensions
"
,
()
=>
{
it
(
"
should be create a fill that cover the query, using the parents of sub dimensions
"
,
()
=>
{
...
@@ -244,11 +248,16 @@ describe("engine class", () => {
...
@@ -244,11 +248,16 @@ describe("engine class", () => {
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
childViews
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
.
length
===
0
);
expect
(
optimalView
.
metrics
).
to
.
have
.
length
(
0
);
expect
(
optimalView
.
dimensions
.
length
===
2
);
expect
(
optimalView
.
dimensions
).
to
.
have
.
length
(
2
);
expect
(
optimalView
.
childViews
.
length
===
1
);
expect
(
optimalView
.
childViews
).
to
.
have
.
length
(
1
);
expect
(
optimalView
.
id
===
views
[
0
].
id
);
expect
(
optimalView
).
satisfy
((
optView
:
View
)
=>
{
return
optView
.
childViews
[
0
].
dimensions
.
some
((
item
)
=>
item
.
name
===
subdim3
.
name
);
});
expect
(
optimalView
).
satisfy
((
optView
:
View
)
=>
{
return
optView
.
childViews
[
0
].
dimensions
.
some
((
item
)
=>
item
.
name
===
subdim5
.
name
);
});
});
});
it
(
"
should throw an exception, sub-dimension with non-existent parent
"
,
()
=>
{
it
(
"
should throw an exception, sub-dimension with non-existent parent
"
,
()
=>
{
...
@@ -261,6 +270,6 @@ describe("engine class", () => {
...
@@ -261,6 +270,6 @@ describe("engine class", () => {
expect
(
e
.
message
).
to
.
be
.
equal
(
"
Engine sub-dimention
"
+
subdim4
.
name
+
"
with no parent
"
);
expect
(
e
.
message
).
to
.
be
.
equal
(
"
Engine sub-dimention
"
+
subdim4
.
name
+
"
with no parent
"
);
}
}
expect
(
error
);
expect
(
error
)
.
to
.
be
.
true
;
});
});
});
});
This diff is collapsed.
Click to expand it.
src/core/engine.ts
+
4
−
2
View file @
5a23cb47
...
@@ -166,8 +166,10 @@ export class Engine {
...
@@ -166,8 +166,10 @@ export class Engine {
// If all the metrics and dimensions are the same and only exist one child view
// If all the metrics and dimensions are the same and only exist one child view
// return this single child view
// return this single child view
if
(
optimalViews
.
length
===
1
&&
if
(
optimalViews
.
length
===
1
&&
q
.
metrics
.
every
((
item
)
=>
optimalViews
[
0
].
view
.
metrics
.
indexOf
(
item
)
!==
-
1
)
&&
optimalViews
[
0
].
view
.
metrics
.
length
===
q
.
metrics
.
length
&&
q
.
dimensions
.
every
((
item
)
=>
optimalViews
[
0
].
view
.
dimensions
.
indexOf
(
item
)
!==
-
1
))
{
optimalViews
[
0
].
view
.
dimensions
.
length
===
q
.
dimensions
.
length
&&
optimalViews
[
0
].
view
.
metrics
.
every
((
item
)
=>
q
.
metrics
.
indexOf
(
item
)
!==
-
1
)
&&
optimalViews
[
0
].
view
.
dimensions
.
every
((
item
)
=>
q
.
dimensions
.
indexOf
(
item
)
!==
-
1
))
{
return
optimalViews
[
0
].
view
;
return
optimalViews
[
0
].
view
;
}
}
else
{
else
{
...
...
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