Skip to content

Commit a8fd42e

Browse files
authored
Merge pull request #3826 from reubenmiller/test-dir-file-count-assertion
test: improve directory file count assertion
2 parents 61154cd + 4ce495e commit a8fd42e

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
robotframework-devicelibrary[docker] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.22.2
1+
robotframework-devicelibrary[docker] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.23.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
robotframework-devicelibrary[local] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.22.2
1+
robotframework-devicelibrary[local] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.23.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
robotframework-devicelibrary[ssh] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.22.2
1+
robotframework-devicelibrary[ssh] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.23.0
22
robotframework-sshlibrary~=3.8.0

tests/RobotFramework/tests/tedge_write.robot

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ ${REGULAR_USER} user
3434

3535
*** Test Cases ***
3636
Sudo elevates permissions when tedge-write writes to a root-owned file
37-
${dest_file}= Create a temporary file
37+
${dir} ${dest_file}= Create a temporary file
3838
Make file inaccessible to regular users ${dest_file}
3939

4040
Write content to file using sudo tedge-write as user tedge ${dest_file}
4141

42-
There should be no leftover temporary files ${dest_file}
42+
There should be no leftover temporary files ${dir}
4343

4444
Sudo doesn't elevate permissions when tedge-write is run by another user
45-
${dest_file}= Create a temporary file
45+
${dir} ${dest_file}= Create a temporary file
4646
Make file inaccessible to regular users ${dest_file}
4747

4848
Write content to file using sudo tedge-write as user
4949
... ${REGULAR_USER} ${dest_file} exp_exit_code=!0
5050

51-
There should be no leftover temporary files ${dest_file}
51+
There should be no leftover temporary files ${dir}
5252

5353
Creates a destination file if it doesn't exist
5454
[Template] Creates a destination file if it doesn't exist
@@ -73,31 +73,31 @@ Preserves permissions if a destination exists
7373
Creates a destination file if it doesn't exist
7474
[Arguments] ${umask}
7575

76-
${dest_filename}= Create a temporary file dry_run=${True}
76+
${dir} ${dest_filename}= Create a temporary file dry_run=${True}
7777
# `tedge-write` is prepended with `umask ${umask}` because new umask only applies to the current
7878
# process, and `Execute Command` starts a new shell process every time
7979
Execute Command as user tedge
8080
... umask ${umask} && echo abc | sudo tedge-write ${dest_filename} strip=True
8181

8282
Path Should Have Permissions ${dest_filename} owner_group=root:root
8383

84-
There should be no leftover temporary files ${dest_filename}
84+
There should be no leftover temporary files ${dir}
8585

8686
Changes permissions if a destination doesn't exist
8787
[Arguments] ${umask}
8888

89-
${dest_filename}= Create a temporary file dry_run=${True}
89+
${dir} ${dest_filename}= Create a temporary file dry_run=${True}
9090
Execute Command as user tedge
9191
... umask ${umask} && echo abc | sudo tedge-write ${dest_filename} --user tedge --group tedge --mode 700
9292

9393
Path Should Have Permissions ${dest_filename} mode=700 owner_group=tedge:tedge
9494

95-
There should be no leftover temporary files ${dest_filename}
95+
There should be no leftover temporary files ${dir}
9696

9797
Preserves permissions if a destination exists
9898
[Arguments] ${umask}
9999

100-
${dest_file}= Create a temporary file
100+
${dir} ${dest_file}= Create a temporary file
101101
Execute Command chown tedge:tedge ${dest_file}
102102
Execute Command chmod 666 ${dest_file}
103103

@@ -106,7 +106,7 @@ Preserves permissions if a destination exists
106106

107107
Path Should Have Permissions ${dest_file} mode=666 owner_group=tedge:tedge
108108

109-
There should be no leftover temporary files ${dest_file}
109+
There should be no leftover temporary files ${dir}
110110

111111
Custom Setup
112112
Setup register=${False}
@@ -123,7 +123,7 @@ Create a temporary file
123123
[Arguments] ${dry_run}=${False}
124124
${dir}= Execute Command mktemp --tmpdir\=/tmp --directory strip=True
125125
${path}= Execute Command mktemp --tmpdir\=${dir} ${{'--dry-run' if ${dry_run} is True else ''}} strip=True
126-
RETURN ${path}
126+
RETURN ${dir} ${path}
127127

128128
Remove temporary test directories
129129
[Documentation] Remove test directories created in _Create a temporary file_ keyword.
@@ -146,9 +146,7 @@ Execute Command as user
146146
Execute Command sudo -n --user\=${user} bash -c '${command}' &{named}
147147

148148
There should be no leftover temporary files
149-
[Documentation] Assuming ${dest_file} was the only file in a temporary directory that was written to by
149+
[Documentation] Assuming ${dir} was the only file in a temporary directory that was written to by
150150
... tedge-agent, check that there are no other files in the directory after using tedge-write.
151-
[Arguments] ${dest_file}
152-
153-
${num_files}= Execute Command ls $(dirname ${dest_file}) | wc -l strip=True
154-
Should Be Equal ${num_files} 1
151+
[Arguments] ${dir}
152+
Directory Should Have File Count ${dir} minimum=1 maximum=1

0 commit comments

Comments
 (0)