Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
blendb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
C3SL
blendb
Commits
3b0a5eec
Commit
3b0a5eec
authored
Dec 06, 2018
by
rafaelatc3sl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#92
: Improve test coverage
Signed-off-by:
rafaelatc3sl
<
rpd17@c3sl
>
parent
72c00bdc
Pipeline
#18958
passed with stages
in 1 minute and 7 seconds
Changes
26
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
598 additions
and
348 deletions
+598
-348
.gitlab-ci.yml
.gitlab-ci.yml
+2
-13
config/ci_database_test.env.example
config/ci_database_test.env.example
+15
-0
config/ci_monet_test.env.example
config/ci_monet_test.env.example
+0
-8
config/ci_postgres_test.env.example
config/ci_postgres_test.env.example
+0
-8
config/ci_test.yaml.example
config/ci_test.yaml.example
+1
-0
config/market_dimensions.yaml.example
config/market_dimensions.yaml.example
+28
-10
config/market_enum.yaml.example
config/market_enum.yaml.example
+1
-2
config/market_views.yaml.example
config/market_views.yaml.example
+9
-0
config/source_test_only.yaml.example
config/source_test_only.yaml.example
+8
-0
config/test/postgres/fixtures/sellerstatus.json
config/test/postgres/fixtures/sellerstatus.json
+4
-0
src/adapter/monet.ts
src/adapter/monet.ts
+0
-8
src/adapter/postgres.spec.ts
src/adapter/postgres.spec.ts
+239
-211
src/adapter/postgres.ts
src/adapter/postgres.ts
+0
-8
src/api/controllers/collect.spec.ts
src/api/controllers/collect.spec.ts
+61
-34
src/api/controllers/collect.ts
src/api/controllers/collect.ts
+3
-8
src/api/controllers/data.spec.ts
src/api/controllers/data.spec.ts
+89
-1
src/api/controllers/engine.spec.ts
src/api/controllers/engine.spec.ts
+2
-2
src/api/middlewares/error.spec.ts
src/api/middlewares/error.spec.ts
+10
-0
src/core/adapter.ts
src/core/adapter.ts
+0
-5
src/core/engine.spec.ts
src/core/engine.spec.ts
+41
-1
src/core/filter.ts
src/core/filter.ts
+5
-4
src/main.ts
src/main.ts
+4
-4
src/util/configParser.ts
src/util/configParser.ts
+25
-14
src/util/scenarioHandler.ts
src/util/scenarioHandler.ts
+12
-0
test/postgres/fixtures/sellerstatus.json
test/postgres/fixtures/sellerstatus.json
+4
-0
test/scenario.ts
test/scenario.ts
+35
-7
No files found.
.gitlab-ci.yml
View file @
3b0a5eec
...
...
@@ -24,22 +24,11 @@ stages:
-
deploy
run_test
_postgres
:
run_test
:
stage
:
test
script
:
-
yarn install --frozen-lockfile --silent --non-interactive
-
mv config/ci_postgres_test.env.example config/test.env
-
yarn test
-
yarn run lint
tags
:
-
node
-
postgres
run_test_monet
:
stage
:
test
script
:
-
yarn install --frozen-lockfile --silent --non-interactive
-
mv config/ci_monet_test.env.example config/test.env
-
mv config/ci_database_test.env.example config/test.env
-
yarn test
-
yarn run lint
tags
:
...
...
config/ci_database_test.env.example
0 → 100644
View file @
3b0a5eec
PORT=3000
BLENDB_N_DB=2
BLENDB_DB0_USER=runner
BLENDB_DB0_NAME=blendb_fixture
BLENDB_DB0_PASSWORD=
BLENDB_DB0_HOST=postgres
BLENDB_DB0_PORT=5432
BLENDB_DB0_ADAPTER=postgres
BLENDB_DB1_USER=monetdb
BLENDB_DB1_NAME=blendb_fixture
BLENDB_DB1_PASSWORD=monetdb
BLENDB_DB1_HOST=monet
BLENDB_DB1_PORT=50000
BLENDB_DB1_ADAPTER=monet
BLENDB_SCHEMA_FILE=config/ci_test.yaml.example
config/ci_monet_test.env.example
deleted
100644 → 0
View file @
72c00bdc
BLENDB_DB_USER=monetdb
BLENDB_DB_NAME=blendb_fixture
BLENDB_DB_PASSWORD=monetdb
BLENDB_DB_HOST=monet
BLENDB_DB_PORT=50000
BLENDB_ADAPTER=monet
BLENDB_SCHEMA_FILE=config/ci_test.yaml.example
PORT=3000
config/ci_postgres_test.env.example
deleted
100644 → 0
View file @
72c00bdc
BLENDB_DB_USER=runner
BLENDB_DB_NAME=blendb_fixture
BLENDB_DB_PASSWORD=
BLENDB_DB_HOST=postgres
BLENDB_DB_PORT=5432
BLENDB_ADAPTER=postgres
BLENDB_SCHEMA_FILE=config/ci_test.yaml.example
PORT=3000
config/ci_test.yaml.example
View file @
3b0a5eec
...
...
@@ -46,6 +46,7 @@ enumTypes:
sources:
links:
- config/market_sources.yaml.example
- config/source_test_only.yaml.example
obj:
-
name: "Seller"
...
...
config/market_dimensions.yaml.example
View file @
3b0a5eec
...
...
@@ -19,27 +19,27 @@
-
name: "dim:product:name"
dataType: "string"
description: "Name of the product from market"
description: "Name of the product from market"
-
name: "dim:product:validity"
dataType: "date"
description: "Validity of the product from market"
-
-
name: "dim:client:name"
dataType: "string"
description: "Name of the client from market"
-
-
name: "dim:client:cpf"
dataType: "string"
description: "CPF of the client from market"
-
name: "dim:sell:registered"
dataType: "boolean"
description: "Check if the client is registered"
description: "Check if the client is registered"
-
name: "dim:seller:id"
dataType: "integer"
description: "id of the seller from market"
description: "id of the seller from market"
-
name: "dim:client:id"
dataType: "integer"
...
...
@@ -47,21 +47,39 @@
-
name: "dim:sell:datein"
dataType: "date"
description: "Date of the sell was realized"
description: "Date of the sell was realized"
-
name: "dim:buyout:datein"
dataType: "date"
description: "Date of the buyout was realized"
description: "Date of the buyout was realized"
-
name: "dim:product:id"
dataType: "integer"
description: "id of the product from market"
description: "id of the product from market"
-
name: "dim:provider:name"
dataType: "string"
description: "Name of the provider from market"
description: "Name of the provider from market"
-
name: "dim:provider:id"
dataType: "string"
description: "id of the provider from market"
description: "id of the provider from market"
-
name: "dim:buyout:day"
dataType: "integer"
parent: "dim:buyout:datein"
relation: "day"
description: "Date of the buyout was realized"
-
name: "dim:buyout:month"
dataType: "integer"
parent: "dim:buyout:datein"
relation: "month"
description: "Date of the buyout was realized"
-
name: "dim:buyout:year"
dataType: "integer"
parent: "dim:buyout:datein"
relation: year
description: "Date of the buyout was realized"
config/market_enum.yaml.example
View file @
3b0a5eec
...
...
@@ -13,5 +13,4 @@
- "vacation"
- "sick leave"
- "maternity leave"
- "stand by"
config/market_views.yaml.example
View file @
3b0a5eec
...
...
@@ -79,3 +79,12 @@
- "met:seller:max:age"
clauses:
- "dim:seller:status==active"
-
alias: "view:SellerStatus"
data: "test/postgres/fixtures/sellerstatus.json"
origin: false
aliasAsName: true
metrics:
- "met:seller:count:age"
dimensions:
- "dim:seller:status"
config/source_test_only.yaml.example
0 → 100644
View file @
3b0a5eec
-
name: "test"
description:
fields:
-
name: "noDescriptionString"
description:
dataType: "string"
config/test/postgres/fixtures/sellerstatus.json
0 → 100644
View file @
3b0a5eec
[
{
"met:seller:count:age"
:
4
,
"dim:seller:status"
:
"active"
},
{
"met:seller:count:age"
:
1
,
"dim:seller:status"
:
"sick leave"
}
]
src/adapter/monet.ts
View file @
3b0a5eec
...
...
@@ -142,14 +142,6 @@ export class MonetAdapter extends SQLAdapter {
pool
.
close
();
}
/**
* Materialize a given view.
* @param view - View to be materialized.
*/
public
materializeView
(
view
:
View
):
boolean
{
return
false
;
}
/**
* Asynchronously insert one register into a given Source.
* @param source - Insertion "location".
...
...
src/adapter/postgres.spec.ts
View file @
3b0a5eec
This diff is collapsed.
Click to expand it.
src/adapter/postgres.ts
View file @
3b0a5eec
...
...
@@ -86,14 +86,6 @@ export class PostgresAdapter extends SQLAdapter {
this
.
executeQuery
(
query
,
cb
);
}
/**
* Materialize a given view.
* @param view - View to be materialized.
*/
public
materializeView
(
view
:
View
):
boolean
{
return
false
;
}
/**
* Cast BlenDB data types to be used in PostgreSQL queries.
* @param quotedValue - SQL query attribute wrapped by quotes.
...
...
src/api/controllers/collect.spec.ts
View file @
3b0a5eec
...
...
@@ -22,53 +22,80 @@ import * as request from "supertest";
import
{
expect
}
from
"
chai
"
;
import
*
as
server
from
"
../../main
"
;
import
{
Adapter
}
from
"
../../core/adapter
"
;
import
{
ConfigParser
}
from
"
../../util/configParser
"
;
import
{
ConfigParser
,
ParsedConfig
}
from
"
../../util/configParser
"
;
import
{
Fixture
as
FixPostgres
}
from
"
../../../test/postgres/fixture
"
;
import
{
Fixture
as
FixMonet
}
from
"
../../../test/monet/fixture
"
;
import
{
MonetAdapter
,
MonetConfig
}
from
"
../../adapter/monet
"
;
import
{
PostgresAdapter
}
from
"
../../adapter/postgres
"
;
import
{
eachOf
}
from
"
async
"
;
import
{
Source
}
from
"
../../core/source
"
;
describe
(
"
API collect controller
"
,
()
=>
{
let
adapter
:
Adapter
[]
=
[];
let
fixture
;
let
config
:
ParsedConfig
;
function
loadDb
(
db
:
string
,
index
:
number
,
cb
:
(
err
:
any
,
result
:
Adapter
)
=>
void
):
void
{
let
adapter
:
Adapter
;
if
(
db
===
"
postgres
"
)
{
fixture
=
new
FixPostgres
(
config
.
connections
[
index
]);
fixture
.
loadSource
(
config
.
sources
,
(
err
)
=>
{
if
(
err
)
{
throw
err
;
}
adapter
=
new
PostgresAdapter
(
config
.
connections
[
index
]);
cb
(
null
,
adapter
);
});
}
else
if
(
db
===
"
monet
"
)
{
fixture
=
new
FixMonet
(
config
.
connections
[
index
]);
fixture
.
loadSource
(
config
.
sources
,
(
err
)
=>
{
if
(
err
)
{
throw
err
;
}
let
parsedConfig
:
MonetConfig
=
{
user
:
config
.
connections
[
index
].
user
,
dbname
:
config
.
connections
[
index
].
database
,
password
:
config
.
connections
[
index
].
password
,
host
:
config
.
connections
[
index
].
host
,
port
:
config
.
connections
[
index
].
port
};
adapter
=
new
MonetAdapter
(
parsedConfig
);
cb
(
null
,
adapter
);
});
}
else
{
cb
(
"
invalid adapter
"
,
null
);
}
}
describe
(
"
API collect controller
"
,
()
=>
{
// Initializing
let
config
:
any
;
let
adapter
:
Adapter
;
let
fixture
;
before
(
function
(
done
):
void
{
// Arrow function not used to get acces to this and skip the test
// Arrow function not used to get acces to this and skip the test
const
configPath
=
process
.
env
.
BLENDB_SCHEMA_FILE
;
config
=
ConfigParser
.
parse
(
configPath
);
if
(
config
.
adapter
===
"
postgres
"
)
{
fixture
=
new
FixPostgres
(
config
.
connection
);
fixture
.
loadSource
(
config
.
sources
,
(
err
)
=>
{
if
(
err
)
{
throw
err
;
config
=
ConfigParser
.
parse
(
configPath
);
eachOf
(
config
.
adapters
,
function
(
database
,
key
:
number
,
callback
)
{
loadDb
(
database
,
key
,
function
(
err
,
result
)
{
if
(
err
){
return
callback
(
err
)
;
}
adapter
=
new
PostgresAdapter
(
config
.
connection
);
done
();
});
}
else
if
(
config
.
adapter
===
"
monet
"
)
{
fixture
=
new
FixMonet
(
config
.
connection
);
fixture
.
loadSource
(
config
.
sources
,
(
err
)
=>
{
if
(
err
)
{
throw
err
;
else
{
adapter
[
key
]
=
result
;
}
let
parsedConfig
:
MonetConfig
=
{
user
:
config
.
connection
.
user
,
dbname
:
config
.
connection
.
database
,
password
:
config
.
connection
.
password
,
host
:
config
.
connection
.
host
,
port
:
config
.
connection
.
port
};
adapter
=
new
MonetAdapter
(
parsedConfig
);
done
();
callback
();
});
}
else
{
this
.
skip
();
}
},
function
(
err
){
if
(
err
){
this
.
skip
();
}
else
{
done
();
}
});
});
it
(
"
should respond 500 when req.params.class does not exist on Sources
"
,
(
done
)
=>
{
request
(
server
)
.
post
(
"
/v1/collect/thisisjustatest
"
)
...
...
src/api/controllers/collect.ts
View file @
3b0a5eec
...
...
@@ -110,7 +110,7 @@ export class CollectCtrl {
}
else
{
return
false
;
}
}
}
}
};
...
...
@@ -155,16 +155,11 @@ export class CollectCtrl {
"
The value '
"
+
data
[
i
]
+
"
' from '
"
+
fields
[
i
].
name
+
"
' isn't listed on
"
+
fields
[
i
].
enumType
);
}
}
else
if
(
fields
[
i
].
dataType
!==
DataType
.
NONE
){
// check if it's a valid datatype from query
if
(
!
validador
[
EnumHandler
.
stringfyDataType
(
fields
[
i
].
dataType
)](
data
[
i
])
===
true
){
}
else
if
(
!
validador
[
EnumHandler
.
stringfyDataType
(
fields
[
i
].
dataType
)](
data
[
i
])
===
true
){
throw
new
Error
(
"
The value '
"
+
data
[
i
]
+
"
' from '
"
+
fields
[
i
].
name
+
"
' isn't a type
"
+
[
EnumHandler
.
stringfyDataType
(
fields
[
i
].
dataType
)]);
}
}
}
}
}
...
...
src/api/controllers/data.spec.ts
View file @
3b0a5eec
...
...
@@ -192,7 +192,6 @@ describe("API data controller", () => {
})
.
end
(
done
);
});
it
(
"
should respond 200 and get some data, sorted
"
,
(
done
)
=>
{
let
query
=
parseQuery
(
tests
.
clausal
);
query
.
sort
=
"
dim:product:id,met:product:avg:pricein
"
;
...
...
@@ -218,5 +217,94 @@ describe("API data controller", () => {
})
.
end
(
done
);
});
it
(
"
should respond 200 and get some data, using filters with GREATER
"
,
(
done
)
=>
{
let
query
=
parseQuery
(
tests
.
clausal
);
query
.
filters
=
"
dim:product:id>55
"
;
request
(
server
)
.
get
(
"
/v1/data
"
)
.
query
(
query
)
.
expect
(
200
)
.
expect
((
res
:
any
)
=>
{
let
result
=
res
.
body
;
expect
(
result
).
to
.
be
.
an
(
"
array
"
);
expect
(
result
).
to
.
have
.
length
(
2
);
expect
(
result
[
0
]).
to
.
be
.
an
(
"
object
"
);
let
keys
:
string
[]
=
[];
keys
=
keys
.
concat
(
tests
.
clausal
.
metrics
.
map
((
item
)
=>
item
.
name
));
keys
=
keys
.
concat
(
tests
.
clausal
.
dimensions
.
map
((
item
)
=>
item
.
name
));
result
.
forEach
((
row
:
any
)
=>
{
expect
(
row
).
to
.
be
.
an
(
"
object
"
);
expect
(
row
).
to
.
have
.
all
.
keys
(
keys
);
});
})
.
end
(
done
);
});
it
(
"
should respond 200 and get some data, using filters with LOWEREQ
"
,
(
done
)
=>
{
let
query
=
parseQuery
(
tests
.
clausal
);
query
.
filters
=
"
dim:product:id<=55
"
;
request
(
server
)
.
get
(
"
/v1/data
"
)
.
query
(
query
)
.
expect
(
200
)
.
expect
((
res
:
any
)
=>
{
let
result
=
res
.
body
;
expect
(
result
).
to
.
be
.
an
(
"
array
"
);
expect
(
result
).
to
.
have
.
length
(
3
);
expect
(
result
[
0
]).
to
.
be
.
an
(
"
object
"
);
let
keys
:
string
[]
=
[];
keys
=
keys
.
concat
(
tests
.
clausal
.
metrics
.
map
((
item
)
=>
item
.
name
));
keys
=
keys
.
concat
(
tests
.
clausal
.
dimensions
.
map
((
item
)
=>
item
.
name
));
result
.
forEach
((
row
:
any
)
=>
{
expect
(
row
).
to
.
be
.
an
(
"
object
"
);
expect
(
row
).
to
.
have
.
all
.
keys
(
keys
);
});
})
.
end
(
done
);
});
it
(
"
should respond 200 and get some data, using filters with default
"
,
(
done
)
=>
{
let
query
=
parseQuery
(
tests
.
seller
);
query
.
filters
=
"
dim:sell:registered==false
"
;
request
(
server
)
.
get
(
"
/v1/data
"
)
.
query
(
query
)
.
expect
(
200
)
.
expect
((
res
:
any
)
=>
{
let
result
=
res
.
body
;
expect
(
result
).
to
.
be
.
an
(
"
array
"
);
expect
(
result
).
to
.
have
.
length
(
1
);
expect
(
result
[
0
]).
to
.
be
.
an
(
"
object
"
);
let
keys
:
string
[]
=
[];
keys
=
keys
.
concat
(
tests
.
seller
.
metrics
.
map
((
item
)
=>
item
.
name
));
keys
=
keys
.
concat
(
tests
.
seller
.
dimensions
.
map
((
item
)
=>
item
.
name
));
result
.
forEach
((
row
:
any
)
=>
{
expect
(
row
).
to
.
be
.
an
(
"
object
"
);
expect
(
row
).
to
.
have
.
all
.
keys
(
keys
);
});
})
.
end
(
done
);
});
it
(
"
should respond 200 and get some data, using filters with default
"
,
(
done
)
=>
{
let
query
=
parseQuery
(
tests
.
expensive
);
query
.
sort
=
"
met:product:max:pricein
"
request
(
server
)
.
get
(
"
/v1/data
"
)
.
query
(
query
)
.
expect
(
200
)
.
expect
((
res
:
any
)
=>
{
let
result
=
res
.
body
;
expect
(
result
).
to
.
be
.
an
(
"
array
"
);
expect
(
result
).
to
.
have
.
length
(
5
);
expect
(
result
[
0
]).
to
.
be
.
an
(
"
object
"
);
let
keys
:
string
[]
=
[];
keys
=
keys
.
concat
(
tests
.
expensive
.
metrics
.
map
((
item
)
=>
item
.
name
));
keys
=
keys
.
concat
(
tests
.
expensive
.
dimensions
.
map
((
item
)
=>
item
.
name
));
result
.
forEach
((
row
:
any
)
=>
{
expect
(
row
).
to
.
be
.
an
(
"
object
"
);
expect
(
row
).
to
.
have
.
all
.
keys
(
keys
);
});
})
.
end
(
done
);
});
});
src/api/controllers/engine.spec.ts
View file @
3b0a5eec
...
...
@@ -42,7 +42,7 @@ describe("API engine controller", () => {
.
expect
((
res
:
any
)
=>
{
let
result
=
res
.
body
;
expect
(
result
).
to
.
be
.
an
(
"
array
"
);
expect
(
result
).
to
.
have
.
length
(
7
);
expect
(
result
).
to
.
have
.
length
(
8
);
})
.
end
(
done
);
});
...
...
@@ -53,7 +53,7 @@ describe("API engine controller", () => {
.
expect
((
res
:
any
)
=>
{
let
result
=
res
.
body
;
expect
(
result
).
to
.
be
.
an
(
"
array
"
);
expect
(
result
).
to
.
have
.
length
(
1
6
);
expect
(
result
).
to
.
have
.
length
(
1
9
);
})
.
end
(
done
);
});
...
...
src/api/middlewares/error.spec.ts
View file @
3b0a5eec
...
...
@@ -53,4 +53,14 @@ describe("API error middleware", () => {
})
.
end
(
done
);
});
it
(
"
should respond 400 when you connect, and do not send data
"
,
(
done
)
=>
{
request
(
server
)
.
post
(
"
/v1/collect/Seller
"
)
.
expect
(
400
)
.
expect
((
res
:
any
)
=>
{
expect
(
res
.
body
).
to
.
be
.
an
(
"
object
"
);
expect
(
res
.
body
).
to
.
have
.
property
(
"
error
"
);
})
.
end
(
done
);
});
});
src/core/adapter.ts
View file @
3b0a5eec
...
...
@@ -36,11 +36,6 @@ export abstract class Adapter {
* @param cb.result - Data got from view.
*/
public
abstract
getDataFromView
(
view
:
View
,
cb
:
(
err
:
Error
,
result
:
any
[])
=>
void
):
void
;
/**
* Materialize a given view.
* @param view - View to be materialized.
*/
public
abstract
materializeView
(
view
:
View
):
boolean
;
/**
* Asynchronously insert one register into a given Source.
* @param source - Insertion "location".
...
...
src/core/engine.spec.ts
View file @
3b0a5eec
...
...
@@ -23,6 +23,8 @@ import { Engine } from "./engine";
import
{
FilterOperator
}
from
"
./filter
"
;
import
{
View
}
from
"
./view
"
;
import
{
engineScenario
}
from
"
../../test/scenario
"
;
import
{
EnumType
}
from
"
./enumType
"
;
import
{
Dimension
}
from
"
./dimension
"
;
describe
(
"
engine class
"
,
()
=>
{
...
...
@@ -44,7 +46,7 @@ describe("engine class", () => {
expect
(
optimalView
.
metrics
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
dimensions
).
to
.
be
.
an
(
"
array
"
);
expect
(
optimalView
.
metrics
).
to
.
have
.
length
(
16
);
expect
(
optimalView
.
dimensions
).
to
.
have
.
length
(
1
6
);
expect
(
optimalView
.
dimensions
).
to
.
have
.
length
(
1
9
);
});
it
(
"
should throw an exception, query with non-existent metric
"
,
()
=>
{
let
error
:
boolean
=
false
;
...
...
@@ -288,4 +290,42 @@ describe("engine class", () => {
expect
(
clause
.
filters
[
0
].
operator
).
to
.
be
.
equal
(
operators
[
op
]);
}
});
it
(
"
should return all views
"
,
()
=>
{
let
views
:
View
[];
views
=
engine
.
getViews
();
expect
(
views
).
to
.
have
.
length
(
9
);
for
(
let
i
=
0
;
i
<
views
.
length
;
i
++
){
expect
(
views
[
i
]).
to
.
have
.
property
(
"
metrics
"
);
expect
(
views
[
i
]).
to
.
have
.
property
(
"
dimensions
"
);
expect
(
views
[
i
]).
to
.
have
.
property
(
"
clauses
"
);
expect
(
views
[
i
]).
to
.
have
.
property
(
"
origin
"
);
expect
(
views
[
i
]).
to
.
have
.
property
(
"
operation
"
);
expect
(
views
[
i
]).
to
.
have
.
property
(
"
id
"
);
expect
(
views
[
i
]).
to
.
have
.
property
(
"
name
"
);
}
});
it
(
"
should return null from addView
"
,
()
=>
{
let
view
:
View
;
view
=
engine
.
addView
(
null
);
expect
(
view
).
to
.
be
.
null
;
});
it
(
"
should return null from addDimension
"
,
()
=>
{
let
dimension
:
Dimension
;
dimension
=
engine
.
addDimension
(
null
);
expect
(
dimension
).
to
.
be
.
null
;
});
it
(
"
should return all views
"
,
()
=>
{
let
enumtype
:
EnumType
;
let
error
:
boolean
=
false
;
try
{
enumtype
=
engine
.
getEnumTypeByName
(
"
test
"
);
}
catch
(
e
){
error
=
true
;
expect
(
e
.
message
).
to
.
be
.
equal
(
"
The dataType named 'test' was not found
"
);
}
expect
(
error
);
});
});
src/core/filter.ts
View file @
3b0a5eec
...
...
@@ -183,11 +183,12 @@ export class Filter {
return
false
;
}
if
(
op
.
operator
===
FilterOperator
.
GREATER
||
op
.
operator
===
FilterOperator
.
LOWER
||
if
(
op
.
operator
===
FilterOperator
.
GREATER
||
op
.
operator
===
FilterOperator
.
LOWER
||
op
.
operator
===
FilterOperator
.
GREATEREQ
||
op
.
operator
===
FilterOperator
.
LOWEREQ
)
{
if
(
op
.
target
.
dataType
===
DataType
.
DATE
||
op
.
target
.
dataType
===
DataType
.
INTEGER
)
{
op
.
operator
===
FilterOperator
.
LOWEREQ
)
{
if
(
op
.
target
.
dataType
===
DataType
.
DATE
||
op
.
target
.
dataType
===
DataType
.
INTEGER
)
{
return
true
;
}
...
...
src/main.ts
View file @
3b0a5eec
...
...
@@ -47,12 +47,12 @@ import { PostgresMw, MonetMw } from "./api/middlewares/adapter";
import
{
ErrorMw
}
from
"
./api/middlewares/error
"
;
app
.
use
(
EngineMw
(
config
));
if
(
config
.
adapter
===
"
postgres
"
)
{
app
.
use
(
PostgresMw
(
config
.
connection
));
if
(
config
.
adapter
s
[
0
]
===
"
postgres
"
)
{
app
.
use
(
PostgresMw
(
config
.
connection
s
[
0
]
));
}
else
if
(
config
.
adapter
===
"
monet
"
)
{
app
.
use
(
MonetMw
(
config
.
connection
));
else
if
(
config
.
adapter
s
[
0
]
===
"
monet
"
)
{
app
.
use
(
MonetMw
(
config
.
connection
s
[
0
]
));
}
else
{
...
...
src/util/configParser.ts
View file @
3b0a5eec
...
...
@@ -91,10 +91,10 @@ interface BuildView {
}
export
interface
ParsedConfig
{
/** What adapter
is
in use. */
adapter
:
string
;
/** Connection parameters to connect in the database. */
connection
:
Connection
;
/** What adapter
s are
in use. */
adapter
s
:
string
[]
;
/** Connection
s
parameters to connect in the database. */
connection
s
:
Connection
[]
;
/** Set of all views available. */
views
:
View
[];
/** Set of all sources available. */
...
...
@@ -108,6 +108,8 @@ export interface ParsedConfig {
loadViews
:
LoadView
[];