Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
POD
Commits
29c8b760
Unverified
Commit
29c8b760
authored
4 years ago
by
Vasili Novikov
Browse files
Options
Download
Email Patches
Plain Diff
Fix rustfmt
parent
bc39d1a1
Pipeline
#2766
passed with stage
in 10 minutes and 47 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/database_api.rs
+0
-1
src/database_api.rs
src/database_utils.rs
+59
-16
src/database_utils.rs
src/internal_api.rs
+1
-1
src/internal_api.rs
with
60 additions
and
18 deletions
+60
-18
src/database_api.rs
+
0
-
1
View file @
29c8b760
...
...
@@ -756,5 +756,4 @@ pub mod tests {
Ok
(())
}
}
This diff is collapsed.
Click to expand it.
src/database_utils.rs
+
59
-
16
View file @
29c8b760
...
...
@@ -282,8 +282,8 @@ mod tests {
use
super
::
*
;
use
crate
::
database_api
::
tests
::
new_conn
;
use
crate
::
database_api
::
tests
::
random_id
;
use
serde_json
::
json
;
use
chrono
::
Utc
;
use
serde_json
::
json
;
use
std
::
ops
::
Not
;
#[test]
...
...
@@ -291,27 +291,58 @@ mod tests {
let
mut
conn
=
new_conn
();
let
tx
=
conn
.transaction
()
?
;
let
mut
schema
=
database_api
::
get_schema
(
&
tx
)
.unwrap
();
schema
.property_types
.insert
(
"age"
.to_string
(),
SchemaPropertyType
::
Integer
);
schema
.property_types
.insert
(
"strength"
.to_string
(),
SchemaPropertyType
::
Real
);
schema
.property_types
.insert
(
"myDescription"
.to_string
(),
SchemaPropertyType
::
Text
);
schema
.property_types
.insert
(
"age"
.to_string
(),
SchemaPropertyType
::
Integer
);
schema
.property_types
.insert
(
"strength"
.to_string
(),
SchemaPropertyType
::
Real
);
schema
.property_types
.insert
(
"myDescription"
.to_string
(),
SchemaPropertyType
::
Text
);
let
date
=
Utc
::
now
()
.timestamp_millis
();
let
item
:
Rowid
=
database_api
::
insert_item_base
(
&
tx
,
&
random_id
(),
"Person"
,
date
,
date
,
date
,
false
)
?
;
let
item
:
Rowid
=
database_api
::
insert_item_base
(
&
tx
,
&
random_id
(),
"Person"
,
date
,
date
,
date
,
false
)
?
;
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"age"
,
&
json!
(
20
))
?
.not
());
insert_property
(
&
tx
,
&
schema
,
item
,
"age"
,
&
json!
(
20
))
?
;
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"age"
,
&
json!
(
20
))
?
);
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"age"
,
&
json!
(
20
)
)
?
);
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"age"
,
&
json!
(
99
))
?
.not
());
// Checking non-existing property should yield an error, not a successful "no" response
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"antiAge"
,
&
json!
(
99
))
.is_err
());
insert_property
(
&
tx
,
&
schema
,
item
,
"strength"
,
&
json!
(
13.5
))
?
;
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"strength"
,
&
json!
(
13.5
))
?
);
insert_property
(
&
tx
,
&
schema
,
item
,
"myDescription"
,
&
json!
(
"Wow such person"
))
?
;
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"myDescription"
,
&
json!
(
"Wow such person"
))
?
);
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"strength"
,
&
json!
(
13.5
)
)
?
);
insert_property
(
&
tx
,
&
schema
,
item
,
"myDescription"
,
&
json!
(
"Wow such person"
),
)
?
;
assert!
(
check_item_has_property
(
&
tx
,
&
schema
,
item
,
"myDescription"
,
&
json!
(
"Wow such person"
)
)
?
);
Ok
(())
}
...
...
@@ -321,16 +352,29 @@ mod tests {
let
mut
conn
=
new_conn
();
let
tx
=
conn
.transaction
()
?
;
let
mut
schema
=
database_api
::
get_schema
(
&
tx
)
.unwrap
();
schema
.property_types
.insert
(
"age"
.to_string
(),
SchemaPropertyType
::
Integer
);
schema
.property_types
.insert
(
"strength"
.to_string
(),
SchemaPropertyType
::
Real
);
schema
.property_types
.insert
(
"myDescription"
.to_string
(),
SchemaPropertyType
::
Text
);
schema
.property_types
.insert
(
"age"
.to_string
(),
SchemaPropertyType
::
Integer
);
schema
.property_types
.insert
(
"strength"
.to_string
(),
SchemaPropertyType
::
Real
);
schema
.property_types
.insert
(
"myDescription"
.to_string
(),
SchemaPropertyType
::
Text
);
let
date
=
Utc
::
now
()
.timestamp_millis
();
let
item
:
Rowid
=
database_api
::
insert_item_base
(
&
tx
,
&
random_id
(),
"Person"
,
date
,
date
,
date
,
false
)
?
;
let
item
:
Rowid
=
database_api
::
insert_item_base
(
&
tx
,
&
random_id
(),
"Person"
,
date
,
date
,
date
,
false
)
?
;
insert_property
(
&
tx
,
&
schema
,
item
,
"age"
,
&
json!
(
20
))
?
;
insert_property
(
&
tx
,
&
schema
,
item
,
"strength"
,
&
json!
(
13.5
))
?
;
insert_property
(
&
tx
,
&
schema
,
item
,
"myDescription"
,
&
json!
(
"Wow such person"
))
?
;
insert_property
(
&
tx
,
&
schema
,
item
,
"myDescription"
,
&
json!
(
"Wow such person"
),
)
?
;
{
let
mut
props
=
HashMap
::
new
();
...
...
@@ -366,5 +410,4 @@ mod tests {
Ok
(())
}
}
This diff is collapsed.
Click to expand it.
src/internal_api.rs
+
1
-
1
View file @
29c8b760
...
...
@@ -328,12 +328,12 @@ mod tests {
use
crate
::
api_model
::
CreateItem
;
use
crate
::
command_line_interface
;
use
crate
::
database_api
;
use
crate
::
database_api
::
tests
::
new_conn
;
use
crate
::
error
::
Result
;
use
crate
::
internal_api
;
use
crate
::
internal_api
::
*
;
use
crate
::
plugin_auth_crypto
::
DatabaseKey
;
use
crate
::
schema
::
Schema
;
use
crate
::
database_api
::
tests
::
new_conn
;
use
serde_json
::
json
;
use
std
::
collections
::
HashMap
;
use
warp
::
hyper
::
StatusCode
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets