Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wattsworth
/
lumen-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7aba763f
authored
Aug 22, 2016
by
John Donnal
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
rubocop fixes
parent
6c82e8d4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
20 deletions
app/adapters/db_adapter.rb
app/services/db_folder/update_folder.rb
spec/adapters/db_adapter_spec.rb
spec/factories/db_schema_helper.rb
spec/models/db_spec.rb
spec/services/db/update_db_spec.rb
spec/services/service_status_spec.rb
app/adapters/db_adapter.rb
View file @
7aba763f
...
...
@@ -19,7 +19,8 @@ class DbAdapter
# Create the schema:
# 3 elements: path, attributes, streams
{
path:
entry
[
0
],
{
path:
entry
[
0
],
attributes:
{
data_type:
entry
[
1
],
start_time:
entry
[
2
]
||
0
,
...
...
app/services/db_folder/update_folder.rb
View file @
7aba763f
...
...
@@ -21,7 +21,8 @@ class UpdateFolder
# update the folder attributes from metadata
info
=
__read_info_entry
(
@entries
)
||
{}
@folder
.
update_attributes
(
info
.
slice
(
*
DbFolder
.
defined_attributes
))
info
.
slice
(
*
DbFolder
.
defined_attributes
)
)
# process the contents of the folder
__parse_folder_entries
(
@folder
,
@entries
)
# delete any files or folders still in the
...
...
@@ -114,7 +115,7 @@ class UpdateFolder
# if any entry_group has chunks left, this is a folder
entry_group
.
select
{
|
entry
|
!
entry
[
:chunks
].
empty?
}.
count
==
0
}.
count
.
zero?
end
# create or update a DbFile object at the
...
...
spec/adapters/db_adapter_spec.rb
View file @
7aba763f
...
...
@@ -11,7 +11,8 @@ describe DbAdapter do
expect
(
entry
).
to
include
(
:path
,
:attributes
)
expect
(
entry
[
:attributes
]).
to
(
include
(
:data_type
,
:start_time
,
:end_time
,
:total_rows
,
:total_time
))
:end_time
,
:total_rows
,
:total_time
)
)
end
end
end
spec/factories/db_schema_helper.rb
View file @
7aba763f
...
...
@@ -12,20 +12,23 @@ class DbSchemaHelper
start_time:
0
,
end_time:
0
,
total_rows:
0
,
total_time:
0
}.
merge
(
metadata
),
total_time:
0
}.
merge
(
metadata
),
streams:
__build_streams
(
stream_count
)
}
end
# build stream hash for a file
def
__build_streams
(
count
)
return
{}
unless
count
>
0
return
{}
unless
count
.
positive?
streams
=
[]
(
0
..
(
count
-
1
)).
each
do
|
i
|
streams
<<
{
'name'
:
"stream
#{
i
}
"
,
{
'name'
:
"stream
#{
i
}
"
,
'units'
:
'unit'
,
'column'
:
i
}
'column'
:
i
}
end
streams
end
...
...
spec/models/db_spec.rb
View file @
7aba763f
...
...
@@ -21,9 +21,9 @@ RSpec.describe 'Db' do
expect
(
db_x
.
url
).
to
eq
(
'custom_string'
)
end
it
'can be left as default'
do
nilm
=
Nilm
.
create
(
url:
"base"
)
nilm
=
Nilm
.
create
(
url:
'base'
)
db_x
=
Db
.
new
(
nilm:
nilm
,
url:
''
)
expect
(
db_x
.
url
).
to
eq
(
"base/nilmdb"
)
expect
(
db_x
.
url
).
to
eq
(
'base/nilmdb'
)
end
end
end
spec/services/db/update_db_spec.rb
View file @
7aba763f
...
...
@@ -129,15 +129,14 @@ describe 'UpdateDb' do
# create Db with a file 'temp'
update_with_schema
([
helper
.
entry
(
'/folder1/temp'
),
helper
.
entry
(
'/folder1/info'
,
metadata:
{
name:
'f1'
})
])
metadata:
{
name:
'f1'
})])
temp
=
DbFile
.
find_by_name
(
'temp'
)
# the file 'temp' should be here
expect
(
temp
).
to
be_present
# update Db without 'temp'
update_with_schema
([
helper
.
entry
(
'/folder1/info'
,
metadata:
{
name:
'f1'
})
],
db:
@db
)
metadata:
{
name:
'f1'
})
],
db:
@db
)
# it should be gone
expect
(
DbFile
.
find_by_name
(
'temp'
)).
to
be
nil
# ...and the service should have a warning
...
...
@@ -147,8 +146,7 @@ describe 'UpdateDb' do
# create Db with a folder 'temp'
update_with_schema
([
helper
.
entry
(
'/folder1/stub'
),
helper
.
entry
(
'/folder1/temp/info'
,
metadata:
{
name:
'temp'
})
])
metadata:
{
name:
'temp'
})])
temp
=
DbFolder
.
find_by_name
(
'temp'
)
# the file 'temp' should be here
expect
(
temp
).
to
be_present
...
...
spec/services/service_status_spec.rb
View file @
7aba763f
...
...
@@ -54,16 +54,16 @@ describe 'ServiceStatus' do
child
.
add_warning
(
'test'
)
expect
(
parent
.
absorb_status
(
child
,
action:
ServiceStatus
::
NEVER_FAIL
)
)
.
to
be
true
action:
ServiceStatus
::
NEVER_FAIL
)
)
.
to
be
true
end
it
'fails on errors and warnings with FAIL_ON_WARNING'
do
child
.
add_warning
(
'test'
)
expect
(
parent
.
absorb_status
(
child
,
action:
ServiceStatus
::
FAIL_ON_WARNING
)
)
.
to
be
false
action:
ServiceStatus
::
FAIL_ON_WARNING
)
)
.
to
be
false
end
it
'fails on errors with FAIL_ON_ERROR'
do
child
.
add_error
(
'test'
)
...
...
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