Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit aaf56fe

Browse files
committed
finished tests
1 parent 3128167 commit aaf56fe

File tree

3 files changed

+82
-5
lines changed

3 files changed

+82
-5
lines changed

filebrowser/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ module "filebrowser" {
4040
agent_id = coder_agent.example.id
4141
database_path = ".config/filebrowser.db"
4242
}
43-
```
43+
```

filebrowser/main.test.ts

+79-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,86 @@ import {
66
testRequiredVariables,
77
} from "../test";
88

9-
describe("azure-region", async () => {
9+
describe("filebrowser", async () => {
1010
await runTerraformInit(import.meta.dir);
1111

12-
testRequiredVariables(import.meta.dir, {});
12+
testRequiredVariables(import.meta.dir, {
13+
agent_id: "foo",
14+
});
1315

16+
it("fails with wrong database_path", async () => {
17+
const state = await runTerraformApply(import.meta.dir, {
18+
agent_id: "foo",
19+
database_path: "nofb",
20+
}).catch((e) => {
21+
if (!e.message.startsWith("\nError: Invalid value for variable")) {
22+
throw e;
23+
}
24+
});
25+
});
26+
27+
it("runs with default", async () => {
28+
const state = await runTerraformApply(import.meta.dir, {
29+
agent_id: "foo",
30+
});
31+
const output = await executeScriptInContainer(state, "alpine");
32+
expect(output.exitCode).toBe(0);
33+
expect(output.stdout).toEqual([
34+
"\u001b[0;1mInstalling filebrowser ",
35+
"",
36+
"🥳 Installation comlete! ",
37+
"",
38+
"👷 Starting filebrowser in background... ",
39+
"",
40+
"📂 Serving /root at http://localhost:13339 ",
41+
"",
42+
"Running 'filebrowser --noauth --root /root --port 13339' ",
43+
"",
44+
"📝 Logs at /tmp/filebrowser.log",
45+
]);
46+
});
47+
48+
it("runs with database_path var", async () => {
49+
const state = await runTerraformApply(import.meta.dir, {
50+
agent_id: "foo",
51+
database_path: ".config/filebrowser.db",
52+
});
53+
const output = await executeScriptInContainer(state, "alpine");
54+
expect(output.exitCode).toBe(0);
55+
expect(output.stdout).toEqual([
56+
"\u001b[0;1mInstalling filebrowser ",
57+
"",
58+
"🥳 Installation comlete! ",
59+
"",
60+
"👷 Starting filebrowser in background... ",
61+
"",
62+
"📂 Serving /root at http://localhost:13339 ",
63+
"",
64+
"Running 'filebrowser --noauth --root /root --port 13339 -d .config/filebrowser.db' ",
65+
"",
66+
"📝 Logs at /tmp/filebrowser.log",
67+
]);
68+
});
69+
70+
it("runs with folder var", async () => {
71+
const state = await runTerraformApply(import.meta.dir, {
72+
agent_id: "foo",
73+
folder: "/home/coder/project",
74+
});
75+
const output = await executeScriptInContainer(state, "alpine");
76+
expect(output.exitCode).toBe(0);
77+
expect(output.stdout).toEqual([
78+
"\u001B[0;1mInstalling filebrowser ",
79+
"",
80+
"🥳 Installation comlete! ",
81+
"",
82+
"👷 Starting filebrowser in background... ",
83+
"",
84+
"📂 Serving /home/coder/project at http://localhost:13339 ",
85+
"",
86+
"Running 'filebrowser --noauth --root /home/coder/project --port 13339' ",
87+
"",
88+
"📝 Logs at /tmp/filebrowser.log",
89+
]);
90+
});
1491
});

filebrowser/run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ fi
1919

2020
printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n"
2121

22-
printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n" # -d ${DB_PATH}
22+
printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG}' \n\n"
2323

24-
filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG} >${LOG_PATH} 2>&1 & # -d ${DB_PATH}
24+
filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG} >${LOG_PATH} 2>&1 &
2525

2626
printf "📝 Logs at ${LOG_PATH} \n\n"

0 commit comments

Comments
 (0)