Skip to content

Commit

Permalink
Another test coverage (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonovk authored May 13, 2024
1 parent c00f7a0 commit bd75d37
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--format documentation
--color
--require spec_helper
--order rand
38 changes: 38 additions & 0 deletions spec/app/clients_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,42 @@
end
end
end

describe '#show' do
before do
FileUtils.cp('spec/fixtures/wg0.json', wg_conf_path)
end

context 'when the necessary config is available' do
let(:expected_result) do
{
id: 2,
server_public_key: 'uygGKpQt7gOwrP+bqkiXytafHiM+XqFGc0jtZVJ5bnw=',
address: '10.8.0.3/24',
private_key: 'aN7ye98FKrmydwfA6tHgHE1PbiidWzUJ9cltnies8F4=',
public_key: 'hvIyIW2o8JROVKuY2yYFdUn0oA+43aLuT8KCy0YbORE=',
preshared_key: 'dVW/5kF8wnsx0zAwR4uPIa06btACxpQ/rHBL1B3qPnk=',
allowed_ips: '0.0.0.0/0, ::/0',
dns: '1.1.1.1',
persistent_keepalive: 0,
endpoint: '2.2.2.2:51820',
data: {
cheburek: 'hah'
}
}
end

it 'returns the correct serialized config' do
result = controller.show('2')

expect(result).to eq(expected_result.to_json)
end
end

context 'when the required config is missing' do
it 'raises an error stating that this config is not on the server' do
expect { controller.show('17') }.to raise_error(Errors::ConfigNotFoundError)
end
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require_relative '../app/clients_serializer'
require_relative '../app/clients_controller'
require_relative '../lib/wire_guard/server'
require_relative '../app/errors/config_not_found_error'

require 'super_diff/rspec'

Expand Down

0 comments on commit bd75d37

Please sign in to comment.