Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update FileInfo fixture #6181

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion http/etag_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ Deno.test({
Deno.test({
name: "eTag() handles Deno.FileInfo",
async fn() {
const fixture: Deno.FileInfo = {
const fixture = {
isFile: true,
isDirectory: false,
isSymlink: false,
size: 1024,
mtime: new Date(Date.UTC(96, 1, 2, 3, 4, 5, 6)),
atime: null,
ctime: null,
birthtime: null,
dev: 0,
ino: null,
Expand Down
16 changes: 8 additions & 8 deletions http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import denoConfig from "./deno.json" with { type: "json" };
import { MINUTE } from "@std/datetime/constants";
import { getAvailablePort } from "@std/net/get-available-port";
import { concat } from "@std/bytes/concat";
import { lessThan, parse as parseSemver } from "@std/semver";

const moduleDir = dirname(fromFileUrl(import.meta.url));
const testdataDir = resolve(moduleDir, "testdata");
Expand All @@ -32,6 +33,11 @@ const serveDirOptions: ServeDirOptions = {
showDotfiles: true,
enableCors: true,
};
const denoVersion = parseSemver(Deno.version.deno);
const isCanary = denoVersion.build ? denoVersion.build.length > 0 : false;
// FileInfo.mode is not available on Windows before Deno 2.1.0
const fsModeUnavailable = Deno.build.os === "windows" &&
lessThan(denoVersion, parseSemver("2.1.0")) && !isCanary;

const TEST_FILE_PATH = join(testdataDir, "test_file.txt");
const TEST_FILE_STAT = await Deno.stat(TEST_FILE_PATH);
Expand Down Expand Up @@ -188,10 +194,7 @@ Deno.test("serveDir() serves directory index", async () => {
assertStringIncludes(page, '<a href="/hello.html">hello.html</a>');
assertStringIncludes(page, '<a href="/tls/">tls/</a>');
assertStringIncludes(page, "%2525A.txt");
// `Deno.FileInfo` is not completely compatible with Windows yet
// TODO(bartlomieju): `mode` should work correctly in the future.
// Correct this test case accordingly.
if (Deno.build.os === "windows") {
if (fsModeUnavailable) {
assertMatch(page, /<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/);
} else {
assertMatch(page, /<td class="mode">(\s)*[a-zA-Z- ]{14}(\s)*<\/td>/);
Expand All @@ -212,10 +215,7 @@ Deno.test("serveDir() serves directory index with file containing space in the f
assertStringIncludes(page, '<a href="/hello.html">hello.html</a>');
assertStringIncludes(page, '<a href="/tls/">tls/</a>');
assertStringIncludes(page, "test%20file.txt");
// `Deno.FileInfo` is not completely compatible with Windows yet
// TODO(bartlomieju): `mode` should work correctly in the future.
// Correct this test case accordingly.
if (Deno.build.os === "windows") {
if (fsModeUnavailable) {
assertMatch(page, /<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/);
} else {
assertMatch(page, /<td class="mode">(\s)*[a-zA-Z- ]{14}(\s)*<\/td>/);
Expand Down