This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete preserve integration into @truffle/core
- Add dependencies on the preserve packages (-filecoin) - Add functionality for help function (rather than object) - Add preserve to the list of commands - Add tests to main truffle package
- Loading branch information
Showing
17 changed files
with
219 additions
and
22 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
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
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
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
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,111 @@ | ||
const assert = require("assert"); | ||
const CommandRunner = require("../commandrunner"); | ||
const MemoryLogger = require("../memorylogger"); | ||
const sandbox = require("../sandbox"); | ||
const path = require("path"); | ||
|
||
const logger = new MemoryLogger(); | ||
let config, project; | ||
|
||
const loadSandboxLogger = source => { | ||
project = path.join(__dirname, source); | ||
return sandbox.load(project).then(conf => { | ||
config = conf; | ||
config.logger = logger; | ||
}); | ||
}; | ||
|
||
describe("truffle preserve [ @standalone ]", () => { | ||
// These tests are basically duplicates from "truffle run", but for "truffle preserve" | ||
describe("plugin error handling", () => { | ||
it("should throw when plugins are configured but not installed", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/run/mockProjectWithMissingPluginModule" | ||
); | ||
await assert.rejects(CommandRunner.run("preserve . --mock", config)); | ||
const output = logger.contents(); | ||
assert(output.includes("listed as a plugin, but not found")); | ||
}).timeout(10000); | ||
|
||
it("should throw when plugins are missing truffle-plugin.json", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/run/mockProjectWithMissingPluginConfig" | ||
); | ||
await assert.rejects(CommandRunner.run("preserve . --mock", config)); | ||
const output = logger.contents(); | ||
assert(output.includes("Error: truffle-plugin.json not found")); | ||
}).timeout(10000); | ||
|
||
it("should throw if recipe in truffle-plugin.json uses an absolute path", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/preserve/mockProjectWithAbsolutePath" | ||
); | ||
await assert.rejects(CommandRunner.run("preserve . --mock", config)); | ||
const output = logger.contents(); | ||
assert(output.includes("Error: Absolute paths not allowed!")); | ||
}).timeout(10000); | ||
}); | ||
|
||
describe("preserve error handling", () => { | ||
it("should throw when an unknown environment is specified", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/preserve/mockProjectWithWorkingPlugin" | ||
); | ||
await assert.rejects( | ||
CommandRunner.run("preserve . --mock --environment unknown", config) | ||
); | ||
const output = logger.contents(); | ||
assert(output.includes("Unknown environment")); | ||
}).timeout(20000); | ||
|
||
it("should throw when no recipe is specified", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/preserve/mockProjectWithWorkingPlugin" | ||
); | ||
await assert.rejects(CommandRunner.run("preserve .", config)); | ||
const output = logger.contents(); | ||
assert(output.includes("No (valid) recipe specified")); | ||
}).timeout(20000); | ||
|
||
it("should throw when the specified recipe is not installed", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/preserve/mockProjectWithWorkingPlugin" | ||
); | ||
await assert.rejects(CommandRunner.run("preserve --unknown", config)); | ||
const output = logger.contents(); | ||
assert(output.includes("No (valid) recipe specified")); | ||
}).timeout(20000); | ||
|
||
it("should throw when no target path is specified", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/preserve/mockProjectWithWorkingPlugin" | ||
); | ||
await assert.rejects(CommandRunner.run("preserve --mock", config)); | ||
const output = logger.contents(); | ||
assert(output.includes("No preserve target specified")); | ||
}).timeout(20000); | ||
}); | ||
|
||
describe("success", () => { | ||
it("should run the specified recipe with default environment", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/preserve/mockProjectWithWorkingPlugin" | ||
); | ||
await CommandRunner.run("preserve . --mock", config); | ||
const output = logger.contents(); | ||
assert(output.includes("Provided environment name: development")); | ||
}); | ||
|
||
it("should run the specified recipe with a custom environment", async () => { | ||
await loadSandboxLogger( | ||
"../../sources/preserve/mockProjectWithWorkingPlugin" | ||
); | ||
await CommandRunner.run( | ||
"preserve . --mock --environment production", | ||
config | ||
); | ||
const output = logger.contents(); | ||
assert(output.includes("Provided environment name: production")); | ||
}); | ||
}); | ||
}); |
Empty file.
6 changes: 6 additions & 0 deletions
6
...ources/preserve/mockProjectWithAbsolutePath/node_modules/truffle-mock/truffle-plugin.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
packages/truffle/test/sources/preserve/mockProjectWithAbsolutePath/truffle-config.js
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,3 @@ | ||
module.exports = { | ||
plugins: ["truffle-mock"] | ||
}; |
17 changes: 17 additions & 0 deletions
17
...fle/test/sources/preserve/mockProjectWithWorkingPlugin/node_modules/truffle-mock/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...urces/preserve/mockProjectWithWorkingPlugin/node_modules/truffle-mock/truffle-plugin.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
packages/truffle/test/sources/preserve/mockProjectWithWorkingPlugin/truffle-config.js
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,15 @@ | ||
module.exports = { | ||
plugins: ["truffle-mock"], | ||
environments: { | ||
development: { | ||
mock: { | ||
selectedEnvironment: "development" | ||
} | ||
}, | ||
production: { | ||
mock: { | ||
selectedEnvironment: "production" | ||
} | ||
} | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/truffle/test/sources/preserve/mockProjectWithoutPlugin/truffle-config.js
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 @@ | ||
module.exports = {}; |