1- import { mkdtempSync , writeFileSync } from "node:fs"
2- import { tmpdir } from "node:os"
1+ import { readFileSync } from "node:fs"
32import { dirname , join } from "node:path"
43import { fileURLToPath } from "node:url"
54import { describe , expect , test } from "vitest"
@@ -9,8 +8,10 @@ const __filename = fileURLToPath(import.meta.url)
98const __dirname = dirname ( __filename )
109const fixturesDir = join ( __dirname , "examples" )
1110
12- const destructiveChangeSet = join ( fixturesDir , "destructive_changeset.json" )
13- const safeChangeSet = join ( fixturesDir , "safe_changeset.json" )
11+ const loadChangeSet = ( filePath : string ) => JSON . parse ( readFileSync ( filePath , "utf-8" ) )
12+
13+ const destructiveChangeSet = loadChangeSet ( join ( fixturesDir , "destructive_changeset.json" ) )
14+ const safeChangeSet = loadChangeSet ( join ( fixturesDir , "safe_changeset.json" ) )
1415
1516describe ( "checkDestructiveChanges" , ( ) => {
1617 test ( "returns resources that require replacement" , ( ) => {
@@ -32,8 +33,6 @@ describe("checkDestructiveChanges", () => {
3233 } )
3334
3435 test ( "includes resources marked for removal" , ( ) => {
35- const tempDir = mkdtempSync ( join ( tmpdir ( ) , "changeset-" ) )
36- const removalFixture = join ( tempDir , "removal.json" )
3736 const changeSet = {
3837 Changes : [
3938 {
@@ -47,9 +46,7 @@ describe("checkDestructiveChanges", () => {
4746 }
4847 ]
4948 }
50- writeFileSync ( removalFixture , JSON . stringify ( changeSet ) , "utf-8" )
51-
52- const replacements = checkDestructiveChanges ( removalFixture )
49+ const replacements = checkDestructiveChanges ( changeSet )
5350
5451 expect ( replacements ) . toEqual ( [
5552 {
0 commit comments