kanrisuru 0.8.15 → 0.8.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/path_spec.rb +46 -0
- data/spec/functional/core/stat_spec.rb +3 -5
- data/spec/functional/core/stream_spec.rb +109 -0
- data/spec/helper/expect_helpers.rb +7 -0
- data/spec/spec_helper.rb +3 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c2110c3bfef603ff4d09ade3a4fabf81b34e2f5ca51ff9f120d382963542f7f
|
4
|
+
data.tar.gz: 6ef4e848168e93b37a06e0d0cbfffd9138d979e125d7a151e77c594539aba85d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3444e7a640af911e1f0eb67181503e0b87677847adacd6c0bf3a45c13ce8c8287b2b17ad56ba36d4fe301fe3a19aaf5b17856d3f9bceb1175002ed199d1eb774
|
7
|
+
data.tar.gz: d5a76df5b4ffd4f7483c6953d5c36479755f30efb3e19c822f1df41e459e6213c555c64324f6412df2a9b1ac5a4f003d5e525110c9e6f8e92389d655666fd5d7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## Kanrisuru 0.8.16 (October 14, 20201)
|
2
|
+
* Add functional test cases for `stream` and `path` modules
|
3
|
+
* Create `expect_command` helper for quick testing on raw command result
|
4
|
+
|
1
5
|
## Kanrisuru 0.8.15 (October 12, 20201)
|
2
6
|
* Move functional specs to integration. Anything that performs an actual network request will be under the integrations test.
|
3
7
|
* Create a `StubNetwork` to quickly monkey patch the `Kanrisuru::Remote::Host` to simulate a `Net::SSH` channel request. Will add additional functionality for different simulations later on.
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
StubNetwork.stub!
|
6
|
+
|
7
|
+
RSpec.describe Kanrisuru::Core::Path do
|
8
|
+
let(:host) do
|
9
|
+
Kanrisuru::Remote::Host.new(
|
10
|
+
host: 'localhost',
|
11
|
+
username: 'ubuntu',
|
12
|
+
keys: ['id_rsa']
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'prepares ls command' do
|
17
|
+
expect_command(host.ls(path: '/etc'), 'ls -i -l /etc')
|
18
|
+
expect_command(host.ls(path: '/var/log', all: true, id: true), 'ls -i -l -a -n /var/log')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'prepares pwd command' do
|
22
|
+
expect_command(host.pwd, 'pwd')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'prepares whoami command' do
|
26
|
+
expect_command(host.whoami, 'whoami')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'prepares which command' do
|
30
|
+
expect_command(host.which('which'), 'which which')
|
31
|
+
expect_command(host.which('pwd', all: true), 'which -a pwd')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'prepares realpath command' do
|
35
|
+
expect_command(host.realpath('/etc/os-release'), 'realpath /etc/os-release')
|
36
|
+
expect_command(host.realpath('/etc/os-release', strip: true), 'realpath /etc/os-release -s')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'prepares readlink command' do
|
40
|
+
expect_command(host.readlink('/etc/os-release'), 'readlink /etc/os-release')
|
41
|
+
expect_command(host.readlink('/etc/os-release', canonicalize: true), 'readlink -f /etc/os-release')
|
42
|
+
expect_command(host.readlink('/etc/os-release', canonicalize_existing: true), 'readlink -e /etc/os-release')
|
43
|
+
expect_command(host.readlink('/etc/os-release', canonicalize_missing: true), 'readlink -m /etc/os-release')
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -14,14 +14,12 @@ RSpec.describe Kanrisuru::Core::Stat do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'prepares stat command' do
|
17
|
-
|
18
|
-
expect(result.command.raw_command).to eq(
|
17
|
+
expect_command(host.stat('~/file1.txt'),
|
19
18
|
'stat -c %A,%b,%D,%F,%g,%G,%h,%i,%n,%s,%u,%U,%x,%y,%z ~/file1.txt'
|
20
19
|
)
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
'stat -L -c %A,%b,%D,%F,%g,%G,%h,%i,%n,%s,%u,%U,%x,%y,%z ~/file1.txt'
|
21
|
+
expect_command(host.stat('~/file2.txt', follow: true),
|
22
|
+
'stat -L -c %A,%b,%D,%F,%g,%G,%h,%i,%n,%s,%u,%U,%x,%y,%z ~/file2.txt'
|
25
23
|
)
|
26
24
|
end
|
27
25
|
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
StubNetwork.stub!
|
6
|
+
|
7
|
+
RSpec.describe Kanrisuru::Core::Stream do
|
8
|
+
let(:host) do
|
9
|
+
Kanrisuru::Remote::Host.new(
|
10
|
+
host: 'localhost',
|
11
|
+
username: 'ubuntu',
|
12
|
+
keys: ['id_rsa']
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'prepares head command' do
|
17
|
+
result = host.head('/var/log/syslog')
|
18
|
+
expect_command(result, 'head /var/log/syslog')
|
19
|
+
|
20
|
+
result = host.head('/var/log/syslog', bytes: 1024)
|
21
|
+
expect_command(result, 'head -c 1024 /var/log/syslog')
|
22
|
+
|
23
|
+
result = host.head('/var/log/syslog', lines: 50)
|
24
|
+
expect_command(result, 'head -n 50 /var/log/syslog')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'prepares tail command' do
|
28
|
+
result = host.tail('/var/log/syslog')
|
29
|
+
expect_command(result, 'tail /var/log/syslog' )
|
30
|
+
|
31
|
+
result = host.tail('/var/log/syslog', bytes: 1024)
|
32
|
+
expect_command(result, 'tail -c 1024 /var/log/syslog')
|
33
|
+
|
34
|
+
result = host.tail('/var/log/syslog', lines: 50)
|
35
|
+
expect_command(result, 'tail -n 50 /var/log/syslog' )
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'prepares read_file_chunk command' do
|
39
|
+
result = host.read_file_chunk('/var/log/apache2/access.log', 10, 20)
|
40
|
+
expect_command(result, 'tail -n +10 /var/log/apache2/access.log | head -n 11')
|
41
|
+
|
42
|
+
result = host.read_file_chunk('/var/log/apache2/access.log', 0, 0)
|
43
|
+
expect_command(result, 'tail -n +0 /var/log/apache2/access.log | head -n 1')
|
44
|
+
|
45
|
+
expect {
|
46
|
+
host.read_file_chunk('file.log', 10, '20')
|
47
|
+
}.to raise_error(ArgumentError)
|
48
|
+
|
49
|
+
expect {
|
50
|
+
host.read_file_chunk('file.log', '10', 20)
|
51
|
+
}.to raise_error(ArgumentError)
|
52
|
+
|
53
|
+
expect {
|
54
|
+
host.read_file_chunk('file.log', 10, 9)
|
55
|
+
}.to raise_error(ArgumentError)
|
56
|
+
|
57
|
+
expect {
|
58
|
+
host.read_file_chunk('file.log', -1, 1)
|
59
|
+
}.to raise_error(ArgumentError)
|
60
|
+
|
61
|
+
expect {
|
62
|
+
host.read_file_chunk('file.log', 10, -2)
|
63
|
+
}.to raise_error(ArgumentError)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'prepares sed command' do
|
67
|
+
result = host.sed("~/file.txt", 'Cat', 'Dog')
|
68
|
+
expect_command(result, "sed 's/Cat/Dog/g' '~/file.txt'")
|
69
|
+
|
70
|
+
result = host.sed("~/file.txt", 'Cat', 'Doggz', in_place: true, new_file: '~/file2.txt', mode: 'write')
|
71
|
+
expect_command(result, "sed -i 's/Cat/Doggz/g' '~/file.txt' > ~/file2.txt")
|
72
|
+
|
73
|
+
result = host.sed("~/file.txt", 'Cat', 'Dogo', regexp_extended: true, new_file: '~/file2.txt', mode: 'append')
|
74
|
+
expect_command(result, "sed -r 's/Cat/Dogo/g' '~/file.txt' >> ~/file2.txt")
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'prepares echo command' do
|
78
|
+
expect_command(host.echo('Hello world') , "echo 'Hello world'")
|
79
|
+
expect_command(host.echo("Hello\\n world", backslash: true), "echo -e 'Hello\\n world'")
|
80
|
+
|
81
|
+
expect_command(host.echo('Hello world', new_file: '~/file1.txt', mode: 'write'),
|
82
|
+
"echo 'Hello world' > ~/file1.txt")
|
83
|
+
expect_command(host.echo("Goodbye", new_file: '~/file1.txt', mode: 'append'),
|
84
|
+
"echo 'Goodbye' >> ~/file1.txt")
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'prepares cat command' do
|
88
|
+
expect_command(host.cat('/etc/group'), 'cat /etc/group')
|
89
|
+
expect_command(host.cat('/etc/group', show_all: true), 'cat -A /etc/group')
|
90
|
+
expect_command(host.cat('/etc/group',
|
91
|
+
show_tabs: true,
|
92
|
+
number: true,
|
93
|
+
squeeze_blank: true,
|
94
|
+
show_nonprinting: true,
|
95
|
+
show_ends: true,
|
96
|
+
number_nonblank: true
|
97
|
+
), 'cat -T -n -s -v -E -b /etc/group')
|
98
|
+
|
99
|
+
expect_command(host.cat(['~/file1.txt', '~/file2.txt', '~/file3.txt']),
|
100
|
+
'cat ~/file1.txt ~/file2.txt ~/file3.txt')
|
101
|
+
|
102
|
+
expect_command(host.cat(['~/file1.txt', '~/file2.txt', '~/file3.txt'], mode: 'write', new_file: 'combined.txt'),
|
103
|
+
'cat ~/file1.txt ~/file2.txt ~/file3.txt > combined.txt')
|
104
|
+
|
105
|
+
expect_command(host.cat(['~/file1.txt', '~/file2.txt', '~/file3.txt'], mode: 'append', new_file: 'combined.txt'),
|
106
|
+
'cat ~/file1.txt ~/file2.txt ~/file3.txt >> combined.txt')
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,8 +4,10 @@ require 'simplecov'
|
|
4
4
|
SimpleCov.start
|
5
5
|
|
6
6
|
require 'kanrisuru'
|
7
|
+
|
7
8
|
require_relative 'helper/test_hosts'
|
8
9
|
require_relative 'helper/stub_network'
|
10
|
+
require_relative 'helper/expect_helpers'
|
9
11
|
|
10
12
|
Kanrisuru.logger.level = Logger::WARN
|
11
13
|
|
@@ -19,4 +21,4 @@ RSpec.configure do |config|
|
|
19
21
|
config.expect_with :rspec do |c|
|
20
22
|
c.syntax = :expect
|
21
23
|
end
|
22
|
-
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanrisuru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -173,8 +173,11 @@ files:
|
|
173
173
|
- lib/kanrisuru/util/os_family.rb
|
174
174
|
- lib/kanrisuru/util/signal.rb
|
175
175
|
- lib/kanrisuru/version.rb
|
176
|
+
- spec/functional/core/path_spec.rb
|
176
177
|
- spec/functional/core/stat_spec.rb
|
178
|
+
- spec/functional/core/stream_spec.rb
|
177
179
|
- spec/functional/os_package_spec.rb
|
180
|
+
- spec/helper/expect_helpers.rb
|
178
181
|
- spec/helper/stub_network.rb
|
179
182
|
- spec/helper/test_hosts.rb
|
180
183
|
- spec/hosts.json
|