Skip to content

Commit ad377a9

Browse files
Copilotarturcic
andcommitted
Fix tests to use cross-platform temp directory
Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
1 parent a568e33 commit ad377a9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/__tests__/tools/gitversion/tool.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
22
import * as fs from 'node:fs/promises'
3+
import * as os from 'node:os'
4+
import * as path from 'node:path'
35
import { type IBuildAgent } from '@agents/common'
46
import { type GitVersionOutput, type CommandSettings, type ExecuteSettings, GitVersionTool, IGitVersionSettingsProvider } from '@tools/gitversion'
57

@@ -295,7 +297,7 @@ describe('GitVersionTool', () => {
295297

296298
describe('readGitVersionOutput', () => {
297299
it('should read and parse JSON file correctly', async () => {
298-
const outputFile = '/tmp/test-gitversion-output.json'
300+
const outputFile = path.join(os.tmpdir(), 'test-gitversion-output.json')
299301
const expectedOutput: Partial<GitVersionOutput> = {
300302
Major: 1,
301303
Minor: 2,
@@ -326,7 +328,7 @@ describe('GitVersionTool', () => {
326328
})
327329

328330
it('should throw error for invalid JSON file', async () => {
329-
const outputFile = '/tmp/test-gitversion-invalid.json'
331+
const outputFile = path.join(os.tmpdir(), 'test-gitversion-invalid.json')
330332
const buildAgent = {} as IBuildAgent
331333
tool = new TestGitVersionTool(buildAgent)
332334

0 commit comments

Comments
 (0)