Skip to content

Commit

Permalink
Add example of k6/experimental/fs module
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Sep 8, 2023
1 parent 6bb3adb commit fa1dc96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/experimental/fs/bonjour.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bonjour, tout le monde!
20 changes: 20 additions & 0 deletions examples/experimental/fs/fs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { open } from "k6/experimental/fs";

export const options = {
vus: 100,
iterations: 1000,
};

// As k6 does not support asynchronous code in the init context, yet, we need to
// use a top-level async function to be able to use the `await` keyword.
let file;
(async function () {
file = await open("bonjour.txt");
})();

export default async function () {
const fileinfo = await file.stat();
if (fileinfo.name != "bonjour.txt") {
throw new Error("Unexpected file name");
}
}

0 comments on commit fa1dc96

Please sign in to comment.