Skip to content

Commit e3d6163

Browse files
committed
Added logging supression
1 parent ff1db37 commit e3d6163

File tree

3 files changed

+202
-144
lines changed

3 files changed

+202
-144
lines changed
Lines changed: 138 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,104 @@
1-
import { afterEach, beforeEach, describe, it } from "bdd";
21
import { expect } from "expect";
3-
import { run } from "npm:effection@3.6.0";
4-
import { ensureDir } from "jsr:@std/fs";
5-
import { join } from "jsr:@std/path";
2+
import { beforeEach, describe, it } from "../testing.ts";
3+
import { createTempDir, type TempDir } from "../testing/temp-dir.ts";
64
import { analyzeCommand } from "./analyze.ts";
5+
import { setupLogging } from "../testing/logging.ts";
76

87
describe("Analyze Command", () => {
9-
let testDir: string;
8+
let tempDir: TempDir;
109

11-
beforeEach(async () => {
12-
testDir = await Deno.makeTempDir({ prefix: "ex-publisher-analyze-test-" });
10+
beforeEach(function* () {
11+
yield* setupLogging(false);
12+
tempDir = yield* createTempDir({ prefix: "ex-publisher-analyze-test-" });
1313
});
1414

15-
afterEach(async () => {
16-
await Deno.remove(testDir, { recursive: true });
15+
describe("with an empty workspace", () => {
16+
beforeEach(function* () {
17+
yield* tempDir.withFiles({
18+
"deno.json": JSON.stringify(
19+
{
20+
workspace: [],
21+
imports: {},
22+
},
23+
null,
24+
2,
25+
),
26+
});
27+
});
28+
29+
it("should return empty array when no extensions found", function* () {
30+
const extensions = yield* analyzeCommand({
31+
verbose: false,
32+
workspaceRoot: tempDir.path
33+
});
34+
expect(extensions).toHaveLength(0);
35+
});
1736
});
1837

19-
async function createWorkspaceWithExtensions() {
20-
// Create workspace deno.json
21-
await Deno.writeTextFile(
22-
join(testDir, "deno.json"),
23-
JSON.stringify(
24-
{
25-
workspace: ["./phoenix-utils", "./wizard-toolkit"],
26-
imports: {
27-
"bdd": "jsr:@std/testing@1/bdd",
28-
"expect": "jsr:@std/expect@1",
38+
describe("with extensions present", () => {
39+
beforeEach(function* () {
40+
// Create workspace deno.json
41+
yield* tempDir.withFiles({
42+
"deno.json": JSON.stringify(
43+
{
44+
workspace: ["./phoenix-utils", "./wizard-toolkit"],
45+
imports: {
46+
"bdd": "jsr:@std/testing@1/bdd",
47+
"expect": "jsr:@std/expect@1",
48+
},
2949
},
30-
},
31-
null,
32-
2,
33-
),
34-
);
35-
36-
// Create phoenix-utils extension
37-
const phoenixDir = join(testDir, "phoenix-utils");
38-
await ensureDir(phoenixDir);
50+
null,
51+
2,
52+
),
53+
});
3954

40-
await Deno.writeTextFile(
41-
join(phoenixDir, "ex-publisher.ts"),
42-
`import { defineConfig } from 'ex-publisher';
55+
// Create phoenix-utils extension
56+
yield* tempDir.withWorkspace("phoenix-utils", {
57+
"ex-publisher.ts": `import { defineConfig } from 'ex-publisher';
4358
4459
export default defineConfig({
4560
name: 'phoenix-utils',
4661
description: 'Utilities for phoenix lifecycle management',
4762
effection: ['3', '4'],
4863
registries: ['npm']
4964
});`,
50-
);
51-
52-
await Deno.writeTextFile(
53-
join(phoenixDir, "deno.json"),
54-
JSON.stringify(
55-
{
56-
name: "@effectionx/phoenix-utils",
57-
version: "1.2.3",
58-
exports: "./mod.ts",
59-
},
60-
null,
61-
2,
62-
),
63-
);
64-
65-
// Create wizard-toolkit extension
66-
const wizardDir = join(testDir, "wizard-toolkit");
67-
await ensureDir(wizardDir);
68-
69-
await Deno.writeTextFile(
70-
join(wizardDir, "ex-publisher.ts"),
71-
`import { defineConfig } from 'ex-publisher';
65+
"deno.json": JSON.stringify(
66+
{
67+
name: "@effectionx/phoenix-utils",
68+
version: "1.2.3",
69+
exports: "./mod.ts",
70+
},
71+
null,
72+
2,
73+
),
74+
});
75+
76+
// Create wizard-toolkit extension
77+
yield* tempDir.withWorkspace("wizard-toolkit", {
78+
"ex-publisher.ts": `import { defineConfig } from 'ex-publisher';
7279
7380
export default defineConfig({
7481
name: 'wizard-toolkit',
7582
description: 'Advanced spellcasting utilities',
7683
effection: ['4'],
7784
registries: ['npm', 'jsr']
7885
});`,
79-
);
80-
81-
await Deno.writeTextFile(
82-
join(wizardDir, "deno.json"),
83-
JSON.stringify(
84-
{
85-
name: "@effectionx/wizard-toolkit",
86-
version: "0.5.2",
87-
exports: "./mod.ts",
88-
},
89-
null,
90-
2,
91-
),
92-
);
93-
}
94-
95-
it("should return all discovered extensions when no specific extension requested", async () => {
96-
await createWorkspaceWithExtensions();
97-
98-
await run(function* () {
86+
"deno.json": JSON.stringify(
87+
{
88+
name: "@effectionx/wizard-toolkit",
89+
version: "0.5.2",
90+
exports: "./mod.ts",
91+
},
92+
null,
93+
2,
94+
),
95+
});
96+
});
97+
98+
it("should return all discovered extensions when no specific extension requested", function* () {
9999
const extensions = yield* analyzeCommand({
100100
verbose: false,
101-
workspaceRoot: testDir
101+
workspaceRoot: tempDir.path
102102
});
103103

104104
expect(extensions).toHaveLength(2);
@@ -134,100 +134,94 @@ export default defineConfig({
134134
});
135135
expect(wizardToolkit!.version).toBe("0.5.2");
136136
});
137-
});
138-
139-
it("should return only the requested extension when extName is specified", async () => {
140-
await createWorkspaceWithExtensions();
141137

142-
await run(function* () {
138+
it("should return only the requested extension when extName is specified", function* () {
143139
const extensions = yield* analyzeCommand({
144140
verbose: false,
145141
extName: "phoenix-utils",
146-
workspaceRoot: testDir,
142+
workspaceRoot: tempDir.path,
147143
});
148144

149145
expect(extensions).toHaveLength(1);
150146
expect(extensions[0].name).toBe("phoenix-utils");
151147
expect(extensions[0].version).toBe("1.2.3");
152148
});
153-
});
154-
155-
it("should return empty array when no extensions found", async () => {
156-
// Create workspace with no extensions
157-
await Deno.writeTextFile(
158-
join(testDir, "deno.json"),
159-
JSON.stringify(
160-
{
161-
workspace: [],
162-
imports: {},
163-
},
164-
null,
165-
2,
166-
),
167-
);
168-
169-
await run(function* () {
170-
const extensions = yield* analyzeCommand({
171-
verbose: false,
172-
workspaceRoot: testDir
173-
});
174-
expect(extensions).toHaveLength(0);
175-
});
176-
});
177149

178-
it("should return empty array when requested extension not found", async () => {
179-
await createWorkspaceWithExtensions();
180-
181-
await run(function* () {
150+
it("should return empty array when requested extension not found", function* () {
182151
const extensions = yield* analyzeCommand({
183152
verbose: false,
184153
extName: "nonexistent-extension",
185-
workspaceRoot: testDir,
154+
workspaceRoot: tempDir.path,
186155
});
187156
expect(extensions).toHaveLength(0);
188157
});
189-
});
190158

191-
it("should work with verbose flag enabled", async () => {
192-
await createWorkspaceWithExtensions();
193-
194-
await run(function* () {
159+
it("should work with verbose flag enabled", function* () {
195160
const extensions = yield* analyzeCommand({
196161
verbose: true,
197-
workspaceRoot: testDir
162+
workspaceRoot: tempDir.path
198163
});
199164
expect(extensions).toHaveLength(2);
200165
});
201166
});
202167

203-
it("should use custom workspaceRoot when provided", async () => {
204-
await createWorkspaceWithExtensions();
205-
206-
// Create empty test directory outside the generator
207-
const emptyTestDir = await Deno.makeTempDir({ prefix: "empty-test-" });
208-
await Deno.writeTextFile(
209-
join(emptyTestDir, "deno.json"),
210-
JSON.stringify({ workspace: [] }, null, 2)
211-
);
212-
213-
try {
214-
await run(function* () {
215-
// Test that it works with explicit workspaceRoot
216-
const extensions = yield* analyzeCommand({
217-
verbose: false,
218-
workspaceRoot: testDir
219-
});
220-
expect(extensions).toHaveLength(2);
221-
222-
// Test that it would find nothing in a different directory
223-
const emptyExtensions = yield* analyzeCommand({
224-
verbose: false,
225-
workspaceRoot: emptyTestDir
226-
});
227-
expect(emptyExtensions).toHaveLength(0);
228-
});
229-
} finally {
230-
await Deno.remove(emptyTestDir, { recursive: true });
231-
}
168+
describe("with custom workspaceRoot", () => {
169+
let emptyTempDir: TempDir;
170+
171+
beforeEach(function* () {
172+
// Set up main workspace
173+
yield* tempDir.withFiles({
174+
"deno.json": JSON.stringify(
175+
{
176+
workspace: ["./phoenix-utils"],
177+
imports: {},
178+
},
179+
null,
180+
2,
181+
),
182+
});
183+
184+
yield* tempDir.withWorkspace("phoenix-utils", {
185+
"ex-publisher.ts": `import { defineConfig } from 'ex-publisher';
186+
187+
export default defineConfig({
188+
name: 'phoenix-utils',
189+
description: 'Utilities for phoenix lifecycle management',
190+
effection: ['3', '4'],
191+
registries: ['npm']
192+
});`,
193+
"deno.json": JSON.stringify(
194+
{
195+
name: "@effectionx/phoenix-utils",
196+
version: "1.2.3",
197+
exports: "./mod.ts",
198+
},
199+
null,
200+
2,
201+
),
202+
});
203+
204+
// Create empty test directory using TempDir resource
205+
emptyTempDir = yield* createTempDir({ prefix: "empty-test-" });
206+
yield* emptyTempDir.withFiles({
207+
"deno.json": JSON.stringify({ workspace: [] }, null, 2)
208+
});
209+
});
210+
211+
it("should use custom workspaceRoot when provided", function* () {
212+
// Test that it works with explicit workspaceRoot
213+
const extensions = yield* analyzeCommand({
214+
verbose: false,
215+
workspaceRoot: tempDir.path
216+
});
217+
expect(extensions).toHaveLength(1);
218+
219+
// Test that it would find nothing in a different directory
220+
const emptyExtensions = yield* analyzeCommand({
221+
verbose: false,
222+
workspaceRoot: emptyTempDir.path
223+
});
224+
expect(emptyExtensions).toHaveLength(0);
225+
});
232226
});
233227
});

tasks/ex-publisher/lib/discovery.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { expect } from "expect";
22
import { beforeEach, describe, it } from "../testing.ts";
33
import { createTempDir, type TempDir } from "../testing/temp-dir.ts";
44
import { discoverExtensions } from "./discovery.ts";
5+
import { setupLogging } from "../testing/logging.ts";
56

67
describe("Extension Discovery", () => {
78
let tempDir: TempDir;
89

910
beforeEach(function* () {
11+
yield* setupLogging(false);
1012
tempDir = yield* createTempDir();
1113
});
1214

0 commit comments

Comments
 (0)