Update tests to long function names

pull/7/head
Anton Smirnov 2018-09-14 08:51:40 +03:00
parent 3ef0d24e0a
commit 2236349f5e
2 changed files with 46 additions and 18 deletions

View File

@ -4,40 +4,68 @@ require_relative 'spec_helper'
RSpec.describe Journald::Native do
describe 'sends log entries' do
it 'calls send()' do
it 'calls sd_journal_send()' do
# long function name
expect(
Journald::Native.send(
"PRIORITY=#{Journald::LOG_DEBUG}",
'MESSAGE=test send()',
'SOMEFIELD=some value'
)
Journald::Native.sd_journal_send(
"PRIORITY=#{Journald::LOG_DEBUG}",
'MESSAGE=test send()',
'SOMEFIELD=some value'
)
).to eq(0)
# short function name
expect(
Journald::Native.send(
"PRIORITY=#{Journald::LOG_DEBUG}",
'MESSAGE=test send()',
'SOMEFIELD=some value'
)
).to eq(0)
end
it 'calls print()' do
expect(Journald::Native.print Journald::LOG_DEBUG, 'test print()').to eq(0)
it 'calls sd_journal_print()' do
# long function name
expect(
Journald::Native.sd_journal_print(Journald::LOG_DEBUG, 'test print()')
).to eq(0)
# short function name
expect(
Journald::Native.print(Journald::LOG_DEBUG, 'test print()')
).to eq(0)
end
it 'calls perror()' do
expect(Journald::Native.perror 'test perror()').to eq(0)
it 'calls sd_journal_perror()' do
# long function name
expect(Journald::Native.sd_journal_perror('test perror()')).to eq(0)
# short function name
expect(Journald::Native.perror('test perror()')).to eq(0)
end
it 'calls send() with \0 symbol' do
expect(
Journald::Native.send(
"PRIORITY=#{Journald::LOG_DEBUG}",
"MESSAGE=test\0send() with zero",
"SOMEFIELD=some value\0with zero"
)
Journald::Native.sd_journal_send(
"PRIORITY=#{Journald::LOG_DEBUG}",
"MESSAGE=test\0sd_journal_send() with zero",
"SOMEFIELD=some value\0with zero"
)
).to eq(0)
end
it 'fails on print() with \0 symbol' do
expect{ Journald::Native.print Journald::LOG_DEBUG, "test print()\0with zero" }.to raise_error(ArgumentError, 'string contains null byte')
expect do
Journald::Native.sd_journal_print(
Journald::LOG_DEBUG,
"test sd_journal_print()\0with zero"
)
end.to raise_error(ArgumentError, 'string contains null byte')
end
it 'fails on perror() with \0 symbol' do
expect{ Journald::Native.perror "test perror()\0with zero" }.to raise_error(ArgumentError, 'string contains null byte')
expect do
Journald::Native.sd_journal_perror "test perror()\0with zero"
end.to raise_error(ArgumentError, 'string contains null byte')
end
end
end

View File

@ -1 +1 @@
require_relative '../lib/journald/native'
require 'journald/native'