Skip to content

Commit 345417d

Browse files
Copilotunixfox
andcommitted
Fix TypeScript errors in secret key validation test
Co-authored-by: unixfox <[email protected]>
1 parent 65141ff commit 345417d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/tests/secret_key_validation_test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Deno.test("Secret key validation in Invidious companion config", async (t) => {
3030
} catch (error) {
3131
assert(
3232
false,
33-
`Key "${key}" should be valid but config parsing failed: ${error.message}`,
33+
`Key "${key}" should be valid but config parsing failed: ${error instanceof Error ? error.message : String(error)}`,
3434
);
3535
}
3636
}
@@ -63,12 +63,12 @@ Deno.test("Secret key validation in Invidious companion config", async (t) => {
6363
} catch (error) {
6464
// Verify it's a config parsing error with the right message
6565
assert(
66-
error.message.includes("Failed to parse configuration"),
67-
`Should get config parsing error, got: ${error.message}`,
66+
error instanceof Error && error.message.includes("Failed to parse configuration"),
67+
`Should get config parsing error, got: ${error instanceof Error ? error.message : String(error)}`,
6868
);
6969

7070
// Check that the error contains expected validation message content
71-
const errorStr = error.toString();
71+
const errorStr = error instanceof Error ? error.toString() : String(error);
7272
assert(
7373
errorStr.includes(
7474
"SERVER_SECRET_KEY contains invalid characters",
@@ -103,12 +103,12 @@ Deno.test("Secret key validation in Invidious companion config", async (t) => {
103103
} catch (error) {
104104
// Verify it's a config parsing error
105105
assert(
106-
error.message.includes("Failed to parse configuration"),
107-
`Should get config parsing error, got: ${error.message}`,
106+
error instanceof Error && error.message.includes("Failed to parse configuration"),
107+
`Should get config parsing error, got: ${error instanceof Error ? error.message : String(error)}`,
108108
);
109109

110110
// Check that the error mentions length requirement
111-
const errorStr = error.toString();
111+
const errorStr = error instanceof Error ? error.toString() : String(error);
112112
assert(
113113
errorStr.includes("exactly 16 character") ||
114114
errorStr.includes(
@@ -128,7 +128,7 @@ Deno.test("Secret key validation in Invidious companion config", async (t) => {
128128
await parseConfig();
129129
assert(false, "Should have failed with special character key");
130130
} catch (error) {
131-
const errorStr = error.toString();
131+
const errorStr = error instanceof Error ? error.toString() : String(error);
132132

133133
// Check that the error message contains validation details
134134
assert(
@@ -147,7 +147,7 @@ Deno.test("Secret key validation in Invidious companion config", async (t) => {
147147
await parseConfig();
148148
assert(false, "Should have failed with short key");
149149
} catch (error) {
150-
const errorStr = error.toString();
150+
const errorStr = error instanceof Error ? error.toString() : String(error);
151151
assert(
152152
errorStr.includes("exactly 16 character") ||
153153
errorStr.includes(
@@ -172,7 +172,7 @@ Deno.test("Secret key validation in Invidious companion config", async (t) => {
172172
"Should have failed with short key containing special chars",
173173
);
174174
} catch (error) {
175-
const errorStr = error.toString();
175+
const errorStr = error instanceof Error ? error.toString() : String(error);
176176
// Should get length error since it's checked first
177177
assert(
178178
errorStr.includes("exactly 16 character") ||
@@ -197,7 +197,7 @@ Deno.test("Secret key validation in Invidious companion config", async (t) => {
197197
"Should have failed with missing/empty SERVER_SECRET_KEY",
198198
);
199199
} catch (error) {
200-
const errorStr = error.toString();
200+
const errorStr = error instanceof Error ? error.toString() : String(error);
201201
assert(
202202
errorStr.includes("exactly 16 character") ||
203203
errorStr.includes(

0 commit comments

Comments
 (0)