mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
start backend and file tests
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
32964c1e4e
commit
05b4167971
4 changed files with 55 additions and 2 deletions
|
@ -22,7 +22,7 @@ module Vulcano::Plugins
|
|||
}
|
||||
|
||||
def type
|
||||
:unkown
|
||||
:unknown
|
||||
end
|
||||
|
||||
# The following methods can be overwritten by a derived class
|
||||
|
@ -36,7 +36,7 @@ module Vulcano::Plugins
|
|||
|
||||
def sha256sum
|
||||
res = Digest::SHA256.new
|
||||
res.update(@file.content)
|
||||
res.update(content)
|
||||
res.hexdigest
|
||||
end
|
||||
|
||||
|
|
34
test/unit/plugins_v1_backend_file_test.rb
Normal file
34
test/unit/plugins_v1_backend_file_test.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require 'helper'
|
||||
|
||||
describe 'Vulcano::Plugins::Backend::FileCommon' do
|
||||
before do
|
||||
@backend = Vulcano::Plugins::Backend::FileCommon
|
||||
@test = @backend.new
|
||||
end
|
||||
|
||||
it 'default type is :unkown' do
|
||||
@test.type.must_equal :unknown
|
||||
end
|
||||
|
||||
describe 'with non-empty content' do
|
||||
before do
|
||||
@content = 'Hello World'
|
||||
@test = Class.new(@backend) do
|
||||
def content; 'Hello World'; end
|
||||
end.new
|
||||
end
|
||||
|
||||
it 'must return raw content' do
|
||||
@test.content.must_equal @content
|
||||
end
|
||||
|
||||
it 'must calculate the md5sum of content' do
|
||||
@test.md5sum.must_equal 'b10a8db164e0754105b7a99be72e3fe5'
|
||||
end
|
||||
|
||||
it 'must calculate the sha256sum of content' do
|
||||
@test.sha256sum.must_equal 'a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
19
test/unit/plugins_v1_backend_test.rb
Normal file
19
test/unit/plugins_v1_backend_test.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'helper'
|
||||
|
||||
describe 'Vulcano::Plugins::Backend' do
|
||||
before do
|
||||
@backend = Vulcano::Plugins::Backend
|
||||
@child = Class.new(@backend)
|
||||
end
|
||||
|
||||
it 'provides a name method for registering' do
|
||||
@child.must_respond_to :name
|
||||
@child.name 'test'
|
||||
# check if it's there
|
||||
reg = Vulcano::Backend.registry
|
||||
reg.keys.must_include 'test'
|
||||
reg['test'].must_equal @child
|
||||
# cleanup
|
||||
reg.delete('test')
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue