start backend and file tests

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2015-09-02 04:53:51 +02:00
parent 32964c1e4e
commit 05b4167971
4 changed files with 55 additions and 2 deletions

View file

@ -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

View 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

View 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