forked from eclipse-che/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring CloneGitRepoAPI.spec.ts to work with DevWorkspace generat…
…or tool eclipse-che#22223 Signed-off-by: mdolhalo <mdolhalo@redhat.com>
- Loading branch information
mdolhalo
committed
May 19, 2023
1 parent
96b686f
commit 1da9e70
Showing
5 changed files
with
104 additions
and
78 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 was deleted.
Oops, something went wrong.
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,71 @@ | ||
import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor'; | ||
import { expect } from 'chai'; | ||
import { ShellString } from 'shelljs'; | ||
import { GitUtil } from '../../utils/vsc/GitUtil'; | ||
import { TestConstants } from '../../constants/TestConstants'; | ||
import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigurationHelper'; | ||
import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context'; | ||
|
||
suite(`Empty workspace API test`, async function (): Promise<void> { | ||
// works only for root user | ||
const namespace: string = TestConstants.TS_API_TEST_NAMESPACE ? TestConstants.TS_API_TEST_NAMESPACE : undefined; | ||
let clonedProjectName: string; | ||
let containerWorkDir: string; | ||
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper; | ||
let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor; | ||
let devfileContext: DevfileContext; | ||
let devWorkspaceName: string | undefined; | ||
let containerTerminal: KubernetesCommandLineToolsExecutor.ContainerTerminal; | ||
|
||
const gitRepository: string = 'https://github.com/crw-qe/web-nodejs-sample'; | ||
|
||
suiteSetup('Create empty workspace with OC client', async function (): Promise<void> { | ||
const workspaceName: string = 'empty-' + Math.floor(Math.random() * 1000); | ||
const devfileContent: string = | ||
'schemaVersion: 2.2.0\n' + | ||
'metadata:\n' + | ||
` name: ${workspaceName}\n`; | ||
|
||
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({ | ||
devfileContent, | ||
}); | ||
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext(); | ||
devWorkspaceName = devfileContext?.devWorkspace?.metadata?.name; | ||
kubernetesCommandLineToolsExecutor = new KubernetesCommandLineToolsExecutor(devWorkspaceName, namespace); | ||
containerTerminal = new KubernetesCommandLineToolsExecutor.ContainerTerminal(kubernetesCommandLineToolsExecutor); | ||
}); | ||
|
||
test('Create empty workspace', async function (): Promise<void> { | ||
kubernetesCommandLineToolsExecutor.loginToOcp(); | ||
const devWorkspaceConfigurationYamlString: string = await devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext); | ||
const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString); | ||
expect(output.stdout).contains('condition met'); | ||
}); | ||
|
||
suiteTeardown('Delete workspace', function (): void { | ||
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(); | ||
}); | ||
|
||
suite('Clone public repo without previous setup', function (): void { | ||
suiteTeardown('Delete cloned project', function (): void { | ||
containerTerminal.removeFolder(`${clonedProjectName}`); | ||
}); | ||
|
||
test('Check if public repo can be cloned', function (): void { | ||
containerWorkDir = containerTerminal.pwd().stdout.replace('\n', ''); | ||
const cloneOutput: ShellString = containerTerminal.gitClone(gitRepository); | ||
expect(cloneOutput.stdout + cloneOutput.stderr).includes('Cloning'); | ||
}); | ||
|
||
test('Check if project was created', function (): void { | ||
clonedProjectName = GitUtil.getProjectNameFromGitUrl(gitRepository); | ||
expect(containerTerminal.ls().stdout).includes(clonedProjectName); | ||
}); | ||
|
||
test('Check if files were imported ', function (): void { | ||
expect(containerTerminal.ls(`${containerWorkDir}/${clonedProjectName}`).stdout).includes(TestConstants.TS_SELENIUM_PROJECT_ROOT_FILE_NAME); | ||
}); | ||
}); | ||
}); | ||
|
||
|
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