kanrisuru 0.8.14 → 0.8.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/lib/kanrisuru/core/disk.rb +1 -1
  4. data/lib/kanrisuru/core/find.rb +12 -5
  5. data/lib/kanrisuru/core/stat.rb +1 -3
  6. data/lib/kanrisuru/core/transfer.rb +12 -1
  7. data/lib/kanrisuru/version.rb +1 -1
  8. data/spec/functional/core/find_spec.rb +156 -45
  9. data/spec/functional/core/path_spec.rb +32 -80
  10. data/spec/functional/core/stat_spec.rb +14 -89
  11. data/spec/functional/core/stream_spec.rb +103 -112
  12. data/spec/functional/core/transfer_spec.rb +175 -102
  13. data/spec/helper/expect_helpers.rb +8 -0
  14. data/spec/helper/stub_network.rb +43 -0
  15. data/spec/{functional → integration}/core/apt_spec.rb +0 -0
  16. data/spec/{functional → integration}/core/archive_spec.rb +0 -0
  17. data/spec/{functional → integration}/core/disk_spec.rb +1 -1
  18. data/spec/{functional → integration}/core/dmi_spec.rb +0 -0
  19. data/spec/{functional → integration}/core/file_spec.rb +8 -5
  20. data/spec/integration/core/find_spec.rb +52 -0
  21. data/spec/{functional → integration}/core/group_spec.rb +0 -0
  22. data/spec/{functional → integration}/core/ip_spec.rb +0 -0
  23. data/spec/integration/core/path_spec.rb +93 -0
  24. data/spec/{functional → integration}/core/socket_spec.rb +0 -0
  25. data/spec/integration/core/stat_spec.rb +98 -0
  26. data/spec/integration/core/stream_spec.rb +117 -0
  27. data/spec/{functional → integration}/core/system_spec.rb +0 -0
  28. data/spec/integration/core/transfer_spec.rb +108 -0
  29. data/spec/{functional → integration}/core/user_spec.rb +0 -0
  30. data/spec/{functional → integration}/core/yum_spec.rb +0 -0
  31. data/spec/{functional → integration}/core/zypper_spec.rb +0 -0
  32. data/spec/{functional → integration}/remote/cluster_spec.rb +0 -0
  33. data/spec/{functional → integration}/remote/cpu_spec.rb +0 -0
  34. data/spec/{functional → integration}/remote/env_spec.rb +0 -0
  35. data/spec/{functional → integration}/remote/fstab_spec.rb +0 -0
  36. data/spec/{functional → integration}/remote/host_spec.rb +0 -0
  37. data/spec/{functional → integration}/remote/memory_spec.rb +0 -0
  38. data/spec/{functional → integration}/remote/os_spec.rb +0 -0
  39. data/spec/{functional → integration}/remote/remote_file_spec.rb +0 -0
  40. data/spec/spec_helper.rb +3 -0
  41. data/spec/unit/core/find_spec.rb +3 -0
  42. metadata +29 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1537cdde3ded7563e59018ddb94f1c05bb17ff486c87f6113eaa1800b6f7c338
4
- data.tar.gz: 571b0fef3b4d780d3fac4f485f7f1b1dd14bd3c73253a7b5649ae7e86975fd81
3
+ metadata.gz: 6e813c072c86f8c0b076a90d2b8136fb9bc64271df996c6c54c4e2bf6c7b5806
4
+ data.tar.gz: a763991aa4979eb17c1c0e123d80c2057552b2caf9be24358b39659a292e241d
5
5
  SHA512:
6
- metadata.gz: 2351ae7e335b61a1362c15a08540977c5d366ae2c441882f4feff32bc7939da71312dc5f380fa707a6c3cb187e81d413d558ae55e31e395d069e1a3c5e3f2a08
7
- data.tar.gz: 2fbb6a9649eb2a67c46bc0a617cd22965738dfcbb092b4b99da588ae70518b4a0dfc79aa2da55c58d53f760170a5c33c844a86aae97f56eeed4628c735a65546
6
+ metadata.gz: 52be23f3a72de4d6f9633e8b01470949035aec9be4123a87bbfc2e4a93120c463fa1470a69030ad696fbabb389ce60890b64925d129654f513a4baa392846ca8
7
+ data.tar.gz: 749dfdd773a1256575ab262a73f56be48ec6caaef21e8499ea9fb42d9cb2ae79e569d3f8b9581aa153d9d7031eef88d46c64a9a68900d27e00cf85e28885d45d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## Kanrisuru 0.8.17 (October 16 2021)
2
+ * Add functional test cases for `transfer` module
3
+ * Update wget command to accept hash for `headers` opt.
4
+
5
+ ## Kanrisuru 0.8.16 (October 14, 2021)
6
+ * Add functional test cases for `stream` and `path` modules
7
+ * Create `expect_command` helper for quick testing on raw command result
8
+
9
+ ## Kanrisuru 0.8.15 (October 12, 20201)
10
+ * Move functional specs to integration. Anything that performs an actual network request will be under the integrations test.
11
+ * 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.
12
+ * Start with testing the `stat` command as a functional test.
13
+
1
14
  ## Kanrisuru 0.8.14 (October 8, 20201)
2
15
  * Update `Kanrisuru::Remote::Cluster` instantiation method to use array splat instead of passing array directly.
3
16
 
@@ -23,7 +23,7 @@ module Kanrisuru
23
23
  :name, :label, :uuid, :type, :uuid_sub, :label_fatboot, :version, :usage,
24
24
  :part_uuid, :part_entry_scheme, :part_entry_uuid, :part_entry_type,
25
25
  :part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk,
26
- :minimum_io_size, :physical_sector_size, :logical_sector_size,
26
+ :minimum_io_size, :physical_sector_size, :logical_sector_size
27
27
  )
28
28
 
29
29
  def du(opts = {})
@@ -10,6 +10,7 @@ module Kanrisuru
10
10
  os_define :linux, :find
11
11
 
12
12
  FilePath = Struct.new(:path)
13
+ REGEX_TYPES = ['emacs', 'posix-awk', 'posix-basic', 'posix-egrep', 'posix-extended']
13
14
 
14
15
  def find(opts = {})
15
16
  paths = opts[:paths]
@@ -32,7 +33,7 @@ module Kanrisuru
32
33
  if paths.instance_of?(Array)
33
34
  paths = paths.join(' ')
34
35
  elsif paths.class != String
35
- raise 'Invalid paths type'
36
+ raise ArgumentError, 'Invalid paths type'
36
37
  end
37
38
 
38
39
  command << paths
@@ -64,13 +65,19 @@ module Kanrisuru
64
65
  command.append_arg('-cmin', opts[:cmin])
65
66
  command.append_arg('-mmin', opts[:mmin])
66
67
 
67
- command.append_arg('-regex', "'#{regex}'") if Kanrisuru::Util.present?(regex)
68
+ if Kanrisuru::Util.present?(opts[:regex_type])
69
+ unless REGEX_TYPES.include?(opts[:regex_type])
70
+ raise ArgumentError, 'invalid regex type'
71
+ end
68
72
 
69
- if size.instance_of?(String)
70
- match = Regexp.new(/^([-+]+)\s*?(\d+)([bcwkMG])$/).match(size)
73
+ command.append_arg('-regextype', opts[:regex_type])
74
+ end
71
75
 
72
- raise ArgumentError, "invalid size string: '#{@size}'" if match.nil? || match.captures.include?(nil)
76
+ command.append_arg('-regex', "'#{regex}'") if Kanrisuru::Util.present?(regex)
73
77
 
78
+ if size.instance_of?(String)
79
+ regex = Regexp.new(/^([-+])?(\d+)([bcwkMG])*$/)
80
+ raise ArgumentError, "invalid size string: '#{@size}'" unless regex.match?(size)
74
81
  command.append_arg('-size', size)
75
82
  elsif size.instance_of?(Integer)
76
83
  command.append_arg('-size', size)
@@ -66,10 +66,8 @@ module Kanrisuru
66
66
  end
67
67
 
68
68
  def stat(path, opts = {})
69
- follow = opts[:follow]
70
-
71
69
  command = Kanrisuru::Command.new('stat')
72
- command.append_flag('-L', follow)
70
+ command.append_flag('-L', opts[:follow])
73
71
  command.append_arg('-c', '%A,%b,%D,%F,%g,%G,%h,%i,%n,%s,%u,%U,%x,%y,%z')
74
72
  command << path
75
73
 
@@ -124,7 +124,6 @@ module Kanrisuru
124
124
  command.append_flag('--no-cookies', opts[:no_cookies])
125
125
  command.append_flag('--keep-session-cookies', opts[:keep_session_cookies])
126
126
  command.append_flag('--ignore-length', opts[:ignore_length])
127
- command.append_arg('--header', opts[:header])
128
127
  command.append_arg('--max-redirect', opts[:max_redirect])
129
128
  command.append_arg('--proxy-user', opts[:proxy_user])
130
129
  command.append_arg('--proxy-password', opts[:proxy_password])
@@ -132,6 +131,18 @@ module Kanrisuru
132
131
  command.append_flag('--save-headers', opts[:save_headers])
133
132
  command.append_arg('--user-agent', opts[:user_agent])
134
133
 
134
+ headers = opts[:headers]
135
+ if Kanrisuru::Util.present?(headers)
136
+ if headers.instance_of?(Hash)
137
+ headers.each do |key, value|
138
+ header = "'#{key}: #{value}'"
139
+ command.append_arg('--header', header)
140
+ end
141
+ elsif headers.instance_of?(String)
142
+ command.append_arg('--header', headers)
143
+ end
144
+ end
145
+
135
146
  post_data = opts[:post_data]
136
147
 
137
148
  if Kanrisuru::Util.present?(post_data)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.8.14'
4
+ VERSION = '0.8.18'
5
5
  end
@@ -2,51 +2,162 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
+ StubNetwork.stub!
6
+
5
7
  RSpec.describe Kanrisuru::Core::Find do
6
- TestHosts.each_os do |os_name|
7
- context "with #{os_name}" do
8
- let(:host_json) { TestHosts.host(os_name) }
9
- let(:host) do
10
- Kanrisuru::Remote::Host.new(
11
- host: host_json['hostname'],
12
- username: host_json['username'],
13
- keys: [host_json['ssh_key']]
14
- )
15
- end
16
-
17
- after do
18
- host.disconnect
19
- end
20
-
21
- it 'finds home directory' do
22
- result = host.find(paths: '/home')
23
- home = result.find { |item| item.path == host_json['home'] }
24
- expect(home.path).to eq(host_json['home'])
25
-
26
- result = host.find(paths: ['/home'])
27
- home = result.find { |item| item.path == host_json['home'] }
28
- expect(home.path).to eq(host_json['home'])
29
- end
30
-
31
- it 'finds /etc/hosts file' do
32
- host.su('root')
33
- result = host.find(paths: '/etc', type: 'file', name: 'hosts', uid: 0, gid: 0, writeable: true, maxdepth: 1)
34
- expect(result[0].path).to eq('/etc/hosts')
35
-
36
- file = host.stat(result[0].path)
37
- expect(file.uid).to eq(0)
38
- expect(file.gid).to eq(0)
39
- end
40
-
41
- it 'finds files with regex' do
42
- result = host.find(paths: '~', regex: '.*.\\(js\\|rb\\)')
43
- expect(result.data).to be_instance_of(Array)
44
- end
45
-
46
- it 'finds files by size' do
47
- result = host.find(paths: '~', size: '+2M', type: 'file')
48
- expect(result.data).to be_instance_of(Array)
49
- end
50
- end
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 find command' do
17
+ expect_command(host.find, "find")
18
+
19
+ expect_command(host.find(follow: 'never'), "find -P")
20
+ expect_command(host.find(follow: 'always'), "find -L")
21
+ expect_command(host.find(follow: 'command'), "find -H")
22
+
23
+ expect_command(host.find(paths: '/etc'), "find /etc")
24
+ expect_command(host.find(paths: ['/etc', '/var', '/home']), "find /etc /var /home")
25
+
26
+ expect {
27
+ host.find(paths: 1)
28
+ }.to raise_error(ArgumentError)
29
+
30
+ expect_command(host.find(paths: '/',
31
+ executable: true,
32
+ empty: true,
33
+ readable: true,
34
+ writeable: true,
35
+ nogroup: true,
36
+ nouser: true,
37
+ mount: true
38
+ ),
39
+ "find / -executable -empty -readable -nogroup -nouser -mount"
40
+ )
41
+
42
+ expect_command(host.find(paths: '/',
43
+ path: "/lib",
44
+ name: '*.so',
45
+ gid: 0,
46
+ uid: 0,
47
+ user: 'root',
48
+ group: 'root',
49
+ links: 2,
50
+ mindepth: 0,
51
+ maxdepth: 100
52
+ ),
53
+ "find / -path /lib -name *.so -gid 0 -uid 0 -user root -group root -links 2 -maxdepth 100 -mindepth 0"
54
+ )
55
+
56
+ expect_command(host.find(paths: '/var/log',
57
+ atime: '+1',
58
+ ctime: '+2',
59
+ mtime: '+3',
60
+ amin: '100',
61
+ cmin: '200',
62
+ mmin: '300'
63
+ ),
64
+ "find /var/log -atime +1 -ctime +2 -mtime +3 -amin 100 -cmin 200 -mmin 300"
65
+ )
66
+
67
+ expect_command(host.find(
68
+ paths: '/dev',
69
+ regex: '/dev/tty[0-9]*'
70
+ ),
71
+ "find /dev -regex '/dev/tty[0-9]*'"
72
+ )
73
+
74
+ expect_command(host.find(
75
+ paths: '/dev',
76
+ regex_type: 'posix-egrep',
77
+ regex: '/dev/tty[0-9]*'
78
+ ),
79
+ "find /dev -regextype posix-egrep -regex '/dev/tty[0-9]*'"
80
+ )
81
+
82
+ expect_command(host.find(
83
+ paths: '/var/log',
84
+ size: 100
85
+ ),
86
+ "find /var/log -size 100"
87
+ )
88
+
89
+ expect_command(host.find(
90
+ paths: '/var/log',
91
+ size: "100"
92
+ ),
93
+ "find /var/log -size 100"
94
+ )
95
+
96
+ expect {
97
+ host.find(size: "100n")
98
+ }.to raise_error(ArgumentError)
99
+
100
+ expect_command(host.find(
101
+ paths: '/var/log',
102
+ size: "-100k"
103
+ ),
104
+ "find /var/log -size -100k"
105
+ )
106
+
107
+ expect_command(host.find(
108
+ paths: '/var/log',
109
+ size: "+10M"
110
+ ),
111
+ "find /var/log -size +10M"
112
+ )
113
+
114
+ expect_command(host.find(
115
+ paths: "/dev",
116
+ type: 'directory'
117
+ ),
118
+ "find /dev -type d"
119
+ )
120
+
121
+ expect_command(host.find(
122
+ paths: "/dev",
123
+ type: 'file'
124
+ ),
125
+ "find /dev -type f"
126
+ )
127
+
128
+ expect_command(host.find(
129
+ paths: "/dev",
130
+ type: 'symlinks'
131
+ ),
132
+ "find /dev -type l"
133
+ )
134
+
135
+ expect_command(host.find(
136
+ paths: "/dev",
137
+ type: 'block'
138
+ ),
139
+ "find /dev -type b"
140
+ )
141
+
142
+ expect_command(host.find(
143
+ paths: "/dev",
144
+ type: 'character'
145
+ ),
146
+ "find /dev -type c"
147
+ )
148
+
149
+ expect_command(host.find(
150
+ paths: "/dev",
151
+ type: 'pipe'
152
+ ),
153
+ "find /dev -type p"
154
+ )
155
+
156
+ expect_command(host.find(
157
+ paths: "/dev",
158
+ type: 'socket'
159
+ ),
160
+ "find /dev -type s"
161
+ )
51
162
  end
52
163
  end
@@ -2,92 +2,44 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe Kanrisuru::Core::Path do
6
- TestHosts.each_os do |os_name|
7
- context "with #{os_name}" do
8
- let(:host_json) { TestHosts.host(os_name) }
9
- let(:host) do
10
- Kanrisuru::Remote::Host.new(
11
- host: host_json['hostname'],
12
- username: host_json['username'],
13
- keys: [host_json['ssh_key']]
14
- )
15
- end
16
-
17
- after do
18
- host.disconnect
19
- end
20
-
21
- it 'lists files and directories' do
22
- result = host.ls(all: true)
23
- expect(result.data).to be_instance_of(Array)
24
-
25
- dir = result.find { |file| file.path == '.' }
26
- expect(dir.path).to eq('.')
5
+ StubNetwork.stub!
27
6
 
28
- result = host.ls(path: host_json['home'], id: true, all: true)
29
- expect(result.data).to be_instance_of(Array)
30
-
31
- file = result.find { |f| f.path == '.bashrc' }
32
- expect(file.owner).to eq(1000)
33
-
34
- case os_name
35
- when 'opensuse', 'sles'
36
- expect(file.group).to eq(100)
37
- else
38
- expect(file.group).to eq(1000)
39
- end
40
- end
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
41
15
 
42
- it 'gets whoami' do
43
- expect(host.whoami.user).to eq(host_json['username'])
44
- end
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
45
20
 
46
- it 'gets pwd' do
47
- expect(host.pwd.path).to eq(host_json['home'])
48
- end
21
+ it 'prepares pwd command' do
22
+ expect_command(host.pwd, 'pwd')
23
+ end
49
24
 
50
- it 'uses which to get path for bash' do
51
- result = host.which('bash', all: true)
52
- paths = result.map(&:path)
25
+ it 'prepares whoami command' do
26
+ expect_command(host.whoami, 'whoami')
27
+ end
53
28
 
54
- case os_name
55
- when 'ubuntu'
56
- if host.os.version <= 18.04
57
- expect(paths).to include('/bin/bash')
58
- else
59
- expect(paths).to include('/usr/bin/bash', '/bin/bash')
60
- end
61
- when 'opensuse'
62
- ## Ignore for local testing
63
- when 'sles'
64
- expect(paths).to include('/bin/bash')
65
- else
66
- expect(paths).to include('/usr/bin/bash', '/bin/bash')
67
- end
68
- end
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
69
33
 
70
- it 'gets realpath for dir' do
71
- case os_name
72
- when 'sles'
73
- expect(host.realpath('/var/run').path).to eq('/run')
74
- when 'rhel'
75
- expect(host.realpath('/bin').path).to eq('/usr/bin')
76
- else
77
- expect(host.realpath('/etc/os-release').path).to eq('/usr/lib/os-release')
78
- end
79
- end
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
80
38
 
81
- it 'gets full path for dir with readlink' do
82
- case os_name
83
- when 'sles'
84
- expect(host.readlink('/var/run', canonicalize: true).path).to eq('/run')
85
- when 'rhel'
86
- expect(host.readlink('/bin', canonicalize: true).path).to eq('/usr/bin')
87
- else
88
- expect(host.readlink('/etc/os-release', canonicalize: true).path).to eq('/usr/lib/os-release')
89
- end
90
- end
91
- end
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')
92
44
  end
93
45
  end
@@ -2,97 +2,22 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe Kanrisuru::Core::Stat do
6
- TestHosts.each_os do |os_name|
7
- context "with #{os_name}" do
8
- let(:host_json) { TestHosts.host(os_name) }
9
- let(:host) do
10
- Kanrisuru::Remote::Host.new(
11
- host: host_json['hostname'],
12
- username: host_json['username'],
13
- keys: [host_json['ssh_key']]
14
- )
15
- end
16
-
17
- after do
18
- host.disconnect
19
- end
20
-
21
- it 'checks file type correctly' do
22
- expect(host.dir?('/')).to eq(true)
23
- expect(host.file?('/etc/hosts')).to eq(true)
24
-
25
- case os_name
26
- when 'sles'
27
- expect(host.block_device?('/dev/xvda')).to eq(true)
28
- else
29
- expect(host.block_device?('/dev/vda')).to eq(true)
30
- end
31
-
32
- expect(host.char_device?('/dev/tty')).to eq(true)
33
- expect(host.symlink?('/etc/mtab')).to eq(true)
34
- expect(host.inode?('/proc/uptime')).to eq(true)
35
- end
36
-
37
- it 'gets file stat' do
38
- result = host.stat(host_json['home'])
39
-
40
- expect(result.mode).to be_instance_of(Kanrisuru::Mode)
41
- expect(result.mode.directory?).to eq(true)
42
-
43
- case os_name
44
- when 'centos', 'rhel', 'fedora'
45
- expect(result.mode.numeric).to eq('700')
46
- expect(result.mode.to_i).to eq(0o700)
47
-
48
- expect(result.mode.group.read?).to eq(false)
49
- expect(result.mode.group.write?).to eq(false)
50
- expect(result.mode.group.execute?).to eq(false)
51
-
52
- expect(result.mode.other.read?).to eq(false)
53
- expect(result.mode.other.write?).to eq(false)
54
- expect(result.mode.other.execute?).to eq(false)
5
+ StubNetwork.stub!
55
6
 
56
- expect(result.mode.owner.read?).to eq(true)
57
- expect(result.mode.owner.write?).to eq(true)
58
- expect(result.mode.owner.execute?).to eq(true)
59
-
60
- expect(result.mode.symbolic).to eq('drwx------')
61
- else
62
- expect(result.mode.numeric).to eq('755')
63
- expect(result.mode.to_i).to eq(0o755)
64
-
65
- expect(result.mode.group.read?).to eq(true)
66
- expect(result.mode.group.write?).to eq(false)
67
- expect(result.mode.group.execute?).to eq(true)
68
-
69
- expect(result.mode.other.read?).to eq(true)
70
- expect(result.mode.other.write?).to eq(false)
71
- expect(result.mode.other.execute?).to eq(true)
72
-
73
- expect(result.mode.owner.read?).to eq(true)
74
- expect(result.mode.owner.write?).to eq(true)
75
- expect(result.mode.owner.execute?).to eq(true)
76
-
77
- expect(result.mode.symbolic).to eq('drwxr-xr-x')
78
- end
79
-
80
- expect(result.file_type).to eq('directory')
81
-
82
- case os_name
83
- when 'opensuse', 'sles'
84
- expect(result.gid).to eq(100)
85
- expect(result.group).to eq('users')
86
- else
87
- expect(result.gid).to eq(1000)
88
- expect(result.group).to eq(host_json['username'])
89
- end
7
+ RSpec.describe Kanrisuru::Core::Stat do
8
+ let(:host) do
9
+ Kanrisuru::Remote::Host.new(
10
+ host: 'localhost',
11
+ username: 'ubuntu',
12
+ keys: ['id_rsa']
13
+ )
14
+ end
90
15
 
91
- expect(result.uid).to eq(1000)
92
- expect(result.user).to eq(host_json['username'])
16
+ it 'prepares stat command' do
17
+ expect_command(host.stat('~/file1.txt'),
18
+ 'stat -c %A,%b,%D,%F,%g,%G,%h,%i,%n,%s,%u,%U,%x,%y,%z ~/file1.txt')
93
19
 
94
- expect(result.fsize).to be >= 0
95
- end
96
- end
20
+ expect_command(host.stat('~/file2.txt', follow: true),
21
+ 'stat -L -c %A,%b,%D,%F,%g,%G,%h,%i,%n,%s,%u,%U,%x,%y,%z ~/file2.txt')
97
22
  end
98
23
  end