-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ddfe58
commit e641666
Showing
4 changed files
with
132 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { ResultCodes } from "../../src/cli/result-codes"; | ||
import { emptyProjectManifest } from "../../src/domain/project-manifest"; | ||
import { loadProjectManifestUsing } from "../../src/io/project-manifest-io"; | ||
import { buildProjectManifest } from "../unit/domain/data-project-manifest"; | ||
import { getProjectManifest } from "./check/project-manifest"; | ||
import { runOpenupm } from "./run"; | ||
import { prepareHomeDirectory } from "./setup/directories"; | ||
import { prepareUnityProject } from "./setup/project"; | ||
|
||
describe("remove packages", () => { | ||
it("should not accept package reference with version", async () => { | ||
const homeDirectory = await prepareHomeDirectory(); | ||
const projectDirectory = await prepareUnityProject(homeDirectory); | ||
|
||
const result = await runOpenupm(projectDirectory, [ | ||
"remove", | ||
"dev.comradevanti.opt-unity@2.0.0", | ||
]); | ||
|
||
expect(result.code).toEqual(ResultCodes.Error); | ||
}); | ||
|
||
it("should remove package from manifest", async () => { | ||
const homeDirectory = await prepareHomeDirectory(); | ||
const projectDirectory = await prepareUnityProject(homeDirectory, { | ||
manifest: buildProjectManifest((manifest) => | ||
manifest.addDependency( | ||
"dev.comradevanti.opt-unity", | ||
"2.0.0", | ||
true, | ||
true | ||
) | ||
), | ||
}); | ||
|
||
const result = await runOpenupm(projectDirectory, [ | ||
"remove", | ||
"dev.comradevanti.opt-unity", | ||
]); | ||
|
||
const actualManifest = await getProjectManifest(projectDirectory); | ||
expect(result.code).toEqual(ResultCodes.Ok); | ||
expect(result.stdErr).toEqual( | ||
expect.arrayContaining([ | ||
expect.stringContaining('Removed "dev.comradevanti.opt-unity@2.0.0"'), | ||
expect.stringContaining("please open Unity"), | ||
]) | ||
); | ||
expect(actualManifest).toEqual(emptyProjectManifest); | ||
}); | ||
|
||
it("should fail if package is not in manifest", async () => { | ||
const homeDirectory = await prepareHomeDirectory(); | ||
const projectDirectory = await prepareUnityProject(homeDirectory); | ||
|
||
const result = await runOpenupm(projectDirectory, [ | ||
"remove", | ||
"dev.comradevanti.opt-unity", | ||
]); | ||
|
||
expect(result.code).toEqual(ResultCodes.Error); | ||
expect(result.stdErr).toEqual( | ||
expect.arrayContaining([ | ||
expect.stringContaining( | ||
'Package "dev.comradevanti.opt-unity" could not be found' | ||
), | ||
expect.stringContaining("Did you make a typo"), | ||
]) | ||
); | ||
}); | ||
|
||
it("should be atomic", async () => { | ||
const homeDirectory = await prepareHomeDirectory(); | ||
const initialManifest = buildProjectManifest((manifest) => | ||
manifest.addDependency("dev.comradevanti.opt-unity", "2.0.0", true, true) | ||
); | ||
const projectDirectory = await prepareUnityProject(homeDirectory, { | ||
manifest: initialManifest, | ||
}); | ||
|
||
const result = await runOpenupm(projectDirectory, [ | ||
"remove", | ||
"dev.comradevanti.opt-unity", | ||
"other.unknown.package", | ||
]); | ||
|
||
const actualManifest = await getProjectManifest(projectDirectory); | ||
expect(result.code).toEqual(ResultCodes.Error); | ||
expect(actualManifest).toEqual(initialManifest); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.