summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-02-26 12:04:16 +0200
committerPaul Buetow <paul@buetow.org>2025-02-26 12:04:16 +0200
commit90ddeff0cf134240659003796e28708f046a5030 (patch)
tree2ba2cf44f94acba559397f6f0734163be0bc3a45 /test
parentb394011ce33bd6116bb7d27520d5adea27310862 (diff)
can change owner of files and dirs
Diffstat (limited to 'test')
-rw-r--r--test/lib/dslkeywords/mode_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/lib/dslkeywords/mode_test.rb b/test/lib/dslkeywords/mode_test.rb
index 4102c74..a4bf099 100644
--- a/test/lib/dslkeywords/mode_test.rb
+++ b/test/lib/dslkeywords/mode_test.rb
@@ -46,4 +46,30 @@ class RCMModeTest < Minitest::Test
assert_equal 0o705, File.stat(DIR_PATH).mode.to_s(8).split('')[-4..-1].join.to_i(8)
assert_equal 0o777, File.stat(SYMLINK_TARGET_PATH).mode.to_s(8).split('')[-4..-1].join.to_i(8)
end
+
+ def test_chown
+ configure_from_scratch do
+ # Well, test only makes sense that it doesn't throw any exception, as test
+ # can't change files to other owners as test will likely run as non-root.
+ user_name = Etc.getlogin
+ group_name = Etc.getgrgid(Process.gid).name
+
+ touch FILE1_PATH do
+ owner user_name
+ group group_name
+ end
+ directory DIR_PATH do
+ owner user_name
+ group group_name
+ end
+
+ stat = File.stat(FILE1_PATH)
+ assert_equal user_name, Etc.getpwuid(stat.uid)
+ assert_equal group_name, Etc.getgrgid(stat.gid)
+
+ stat = File.stat(DIR_PATH)
+ assert_equal user_name, Etc.getpwuid(stat.uid)
+ assert_equal group_name, Etc.getgrgid(stat.gid)
+ end
+ end
end