Skip to content

Commit 0cd95e3

Browse files
fs: doc separate chapter (#1565)
1 parent 0cdb19d commit 0cd95e3

16 files changed

Lines changed: 157 additions & 133 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Archive
2+
3+
:include-file: scenarios/fs/archive.groovy {
4+
title: "zip a directory",
5+
surroundedBy: "// zip",
6+
}
7+
8+
# Un-archive
9+
10+
:include-file: scenarios/fs/archive.groovy {
11+
title: "unzip a file",
12+
surroundedBy: "// unzip",
13+
}
14+
15+
:include-file: scenarios/fs/archive.groovy {
16+
title: "untar a file",
17+
surroundedBy: "// untar",
18+
}
19+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copy To A Directory
2+
3+
:include-file: doc-artifacts/snippets/fsCopy/copyFileToDir.groovy {
4+
title: "copy single file to a directory",
5+
includeRegexp: ["fs\\.copy", "createDir"]
6+
}
7+
8+
:include-file: doc-artifacts/snippets/fsCopy/copyFileToTempDir.groovy {
9+
title: "copy single file to a temp directory",
10+
includeRegexp: ["fs\\.copy", "tempDir"]
11+
}
12+
13+
# Replace File
14+
15+
:include-file: doc-artifacts/snippets/fsCopy/copyFileToFile.groovy {
16+
title: "copy single file to a file",
17+
includeRegexp: ["fs\\.copy"]
18+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Validation
2+
3+
:include-file: doc-artifacts/snippets/fsFileContent/readFile.groovy {
4+
title: "validate file content",
5+
surroundedBy: "assert-file"
6+
}
7+
8+
# Content Extraction
9+
10+
Use `.data` to access actual file content for further processing
11+
12+
:include-file: doc-artifacts/snippets/fsFileContent/readFile.groovy {
13+
title: "access file content",
14+
surroundedBy: "actual-file-content"
15+
}
16+
17+
Use `extractByRegexp` to extract content from a file by regular expression
18+
19+
:include-file: doc-artifacts/snippets/fsFileContent/readFile.groovy {
20+
title: "extract file content",
21+
surroundedBy: "extract-id",
22+
excludeRegexp: "statusCode"
23+
}
24+
25+
# Write To File
26+
27+
:include-file: doc-artifacts/snippets/fsFileContent/createFile.groovy {
28+
title: "write content to a file",
29+
includeRegexp: ["fs\\.writeText"]
30+
}
31+
32+
# Replace File Content
33+
34+
Use `replaceText` to replace text in place
35+
36+
:include-file: doc-artifacts/snippets/fsFileContent/replaceFile.groovy {
37+
title: "replace file content",
38+
surroundedBy: "replace-text"
39+
}
40+
41+
```columns
42+
left: :include-file: doc-artifacts/fs-content-to-replace.txt {title: "file to replace"}
43+
right: :include-file: doc-artifacts/fs-content-after-replace-text.txt {title: "result of replace"}
44+
```
45+
46+
# Wait For Content
47+
48+
`fs.textContent` declares file content, but doesn't access it right away.
49+
WebTau reads file content when validation happens. Here is an example of waiting on file content:
50+
51+
:include-file: doc-artifacts/snippets/fsFileContent/readFile.groovy {
52+
title: "wait for a specific file content",
53+
surroundedBy: "wait-for-id"
54+
}
55+
56+
Use `takeSnapshot` and `waitTo change` to wait for any file change:
57+
58+
:include-file: doc-artifacts/snippets/fsFileContent/waitForChange.groovy {
59+
title: "wait for any content change",
60+
surroundedBy: ["file-take-snapshot", "file-wait-to-change"],
61+
surroundedBySeparator: "..."
62+
}
63+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
WebTau provides files system access layer `fs.` to help with files content access, validation and manipulation:
2+
* [Access and validate file content](file-content)
3+
* [Copy files](copy)
4+
* [Archive and Un-archive](archive)
5+
* [Managing temporary files and directories](temporary-files-dirs)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Temporary Dirs
2+
3+
:include-file: scenarios/fs/temp.groovy {
4+
title: "create temp directory",
5+
surroundedBy: "// temp-dir",
6+
}
7+
8+
:include-file: scenarios/fs/temp.groovy {
9+
title: "create temp directory inside directory",
10+
surroundedBy: "// temp-dir-parent",
11+
}
12+
13+
# Temporary Files
14+
15+
:include-file: scenarios/fs/temp.groovy {
16+
title: "create temp file",
17+
surroundedBy: "// temp-file",
18+
}
19+
20+
:include-file: scenarios/fs/temp.groovy {
21+
title: "create temp file inside a directory",
22+
surroundedBy: "// temp-file-parent",
23+
}
24+
25+
:include-file: doc-artifacts/temp-file-path.txt {
26+
title: "example of temp file location"
27+
}
28+
29+
# Automatic Deletion
30+
31+
Note: temp files and temp directories will be automatically deleted at the end of run
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* [replace text content by regexp](utilities/file-system#file-content)
1+
* [replace text content by regexp](file-system/file-content)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* Add `fs.zip` command to [zip files](utilities/file-system#archive)
1+
* Add `fs.zip` command to zip files
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* Fix: [waiting](utilities/file-system) for non-existing file content is **not** throwing error anymore
1+
* Fix: [waiting](file-system/file-content) for non-existing file content is **not** throwing error anymore
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* Wrap deletion of all [temp files](utilities/file-system) in a parent step
1+
* Wrap deletion of all [temp files](file-system/introduction) in a parent step
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* Add [fs.tempFile](utilities/file-system#temporary-dirs-and-files)
1+
* Add `fs.tempFile`

0 commit comments

Comments
 (0)