-
-
Notifications
You must be signed in to change notification settings - Fork 197
Add 'sandbox-pod' command. Implement test. #1052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b6b80de
c7bf25a
5bcca4c
a4da96c
64c6f0b
39a3bec
437baab
a2dfd7d
20f4b26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,21 +39,20 @@ class ProjectIntegrationTest { | |
return projectService.createProject(projectName); | ||
} | ||
|
||
public getDefaultTemplatePath(): IFuture<string> { | ||
public getDefaultTemplatePath(templateName: string): IFuture<string> { | ||
return (() => { | ||
let npmInstallationManager = this.testInjector.resolve("npmInstallationManager"); | ||
let fs = this.testInjector.resolve("fs"); | ||
|
||
let defaultTemplatePackageName = "tns-template-hello-world"; | ||
let cacheRoot = npmInstallationManager.getCacheRootPath(); | ||
let defaultTemplatePath = path.join(cacheRoot, defaultTemplatePackageName); | ||
let latestVersion = npmInstallationManager.getLatestVersion(defaultTemplatePackageName).wait(); | ||
let defaultTemplatePath = path.join(cacheRoot, templateName); | ||
let latestVersion = npmInstallationManager.getLatestVersion(templateName).wait(); | ||
|
||
if(!fs.exists(path.join(defaultTemplatePath, latestVersion)).wait()) { | ||
npmInstallationManager.addToCache(defaultTemplatePackageName, latestVersion).wait(); | ||
npmInstallationManager.addToCache(templateName, latestVersion).wait(); | ||
} | ||
if(!fs.exists(path.join(defaultTemplatePath, latestVersion, "package", "app")).wait()) { | ||
npmInstallationManager.cacheUnpack(defaultTemplatePackageName, latestVersion).wait(); | ||
npmInstallationManager.cacheUnpack(templateName, latestVersion).wait(); | ||
} | ||
|
||
return path.join(defaultTemplatePath, latestVersion, "package"); | ||
|
@@ -118,7 +117,6 @@ class ProjectIntegrationTest { | |
this.testInjector.register("npmInstallationManager", NpmInstallationManagerLib.NpmInstallationManager); | ||
this.testInjector.register("npm", NpmLib.NodePackageManager); | ||
this.testInjector.register("httpClient", HttpClientLib.HttpClient); | ||
this.testInjector.register("config", {}); | ||
this.testInjector.register("lockfile", stubs.LockFile); | ||
|
||
this.testInjector.register("options", optionsLib.Options); | ||
|
@@ -135,7 +133,7 @@ describe("Project Service Tests", () => { | |
let options = projectIntegrationTest.testInjector.resolve("options"); | ||
|
||
options.path = tempFolder; | ||
options.copyFrom = projectIntegrationTest.getDefaultTemplatePath().wait(); | ||
options.copyFrom = projectIntegrationTest.getDefaultTemplatePath("tns-template-hello-world").wait(); | ||
|
||
projectIntegrationTest.createProject(projectName).wait(); | ||
projectIntegrationTest.assertProject(tempFolder, projectName, "org.nativescript.myapp").wait(); | ||
|
@@ -147,12 +145,34 @@ describe("Project Service Tests", () => { | |
let options = projectIntegrationTest.testInjector.resolve("options"); | ||
|
||
options.path = tempFolder; | ||
options.copyFrom = projectIntegrationTest.getDefaultTemplatePath().wait(); | ||
options.copyFrom = projectIntegrationTest.getDefaultTemplatePath("tns-template-hello-world").wait(); | ||
options.appid = "my.special.id"; | ||
|
||
projectIntegrationTest.createProject(projectName).wait(); | ||
projectIntegrationTest.assertProject(tempFolder, projectName, options.appid).wait(); | ||
}); | ||
it("creates valid project and tests pod sandbox", () => { | ||
let testInjector = createTestInjector(); | ||
let fs: IFileSystem = testInjector.resolve("fs"); | ||
let config = testInjector.resolve("config"); | ||
let childProcess = testInjector.resolve("childProcess"); | ||
let projectIntegrationTest = new ProjectIntegrationTest(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tab <-> spaces issue? there's extra white space There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed incorrect spacing. |
||
let workingFolderPath = temp.mkdirSync("ios_project"); | ||
|
||
let iosTemplatePath = path.join(projectIntegrationTest.getDefaultTemplatePath("tns-ios").wait(), "framework/"); | ||
childProcess.exec(`cp -R ${iosTemplatePath} ${workingFolderPath}`, { cwd: workingFolderPath }).wait(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should use either $fs or shelljs |
||
fs.writeFile("/tmp/Podfile/testFile.txt", "Test content.").wait(); | ||
|
||
let postInstallCommmand = `\`cat /tmp/Podfile/testFile.txt > ${workingFolderPath}/copyTestFile.txt && rm -rf /tmp/Podfile\``; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. magic constant used more than once - consider making it a symbol |
||
let podfileContent = `post_install do |installer_representation| ${postInstallCommmand} end`; | ||
fs.writeFile(path.join(workingFolderPath, "Podfile"), podfileContent).wait(); | ||
|
||
let podTool = config.USE_POD_SANDBOX ? "sandbox-pod" : "pod"; | ||
childProcess.spawnFromEvent(podTool, ["install"], "close", { cwd: workingFolderPath, stdio: 'inherit' }).wait(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we call here |
||
|
||
assert.isTrue(fs.exists("/tmp/Podfile").wait()); | ||
assert.isTrue(fs.exists(path.join(workingFolderPath, "copyTestFile.txt")).wait()); | ||
}); | ||
}); | ||
}); | ||
|
||
|
@@ -164,7 +184,6 @@ function createTestInjector() { | |
testInjector.register("projectService", ProjectServiceLib.ProjectService); | ||
testInjector.register("projectHelper", ProjectHelperLib.ProjectHelper); | ||
testInjector.register("projectTemplatesService", stubs.ProjectTemplatesService); | ||
testInjector.register("projectNameValidator", mockProjectNameValidator); | ||
|
||
testInjector.register("fs", fsLib.FileSystem); | ||
testInjector.register("projectDataService", ProjectDataServiceLib.ProjectDataService); | ||
|
@@ -173,7 +192,9 @@ function createTestInjector() { | |
|
||
testInjector.register("npmInstallationManager", NpmInstallationManagerLib.NpmInstallationManager); | ||
testInjector.register("httpClient", HttpClientLib.HttpClient); | ||
testInjector.register("config", {}); | ||
testInjector.register("config", { | ||
"USE_POD_SANDBOX": true | ||
}); | ||
testInjector.register("lockfile", stubs.LockFile); | ||
|
||
testInjector.register("childProcess", ChildProcessLib.ChildProcess); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be renamed for example
getNpmPackagePath(packageName: string)