Skip to content

Commit

Permalink
changed curl for axios
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <mdolhalo@redhat.com>
  • Loading branch information
mdolhalo authored and nallikaea committed May 22, 2023
1 parent a5f3fe9 commit 8aa6599
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
17 changes: 12 additions & 5 deletions tests/e2e/constants/DevfilesRegistryConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { TestConstants } from './TestConstants';
import { ShellExecutor } from '../utils/ShellExecutor';
import axios, { AxiosResponse } from 'axios';
import { Logger } from '../utils/Logger';

function getdevfileRegistryUrl(): string {
function getDevfileRegistryUrl(): string {
return `${TestConstants.TS_SELENIUM_BASE_URL}/devfile-registry/devfiles/`;
}

export const devfileRegistryConstants: object = JSON.parse(
ShellExecutor.curl(getdevfileRegistryUrl()).stdout
);
export const DevfilesRegistryConstants: Promise<object> = (async () => {
let response: AxiosResponse | undefined;
try {
response = await axios.get(getDevfileRegistryUrl());
} catch (error) {
Logger.error(error);
}
return response?.data;
})();
2 changes: 1 addition & 1 deletion tests/e2e/specs/api/DevfileAcceptanceTestAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ suite(`Devfile acceptance test`, async function (): Promise<void> {
let devWorkspaceName: string | undefined;

suiteSetup('Get DevWorkspace configuration from meta.yaml', async function (): Promise<void> {
devfileUrl = GitUtil.getProjectGitLinkFromLinkToMetaYaml(TestConstants.TS_API_TEST_LINK_TO_META_YAML);
devfileUrl = await GitUtil.getProjectGitLinkFromLinkToMetaYaml(TestConstants.TS_API_TEST_LINK_TO_META_YAML);

devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
devfileUrl,
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/utils/vsc/GitUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import { injectable } from 'inversify';
import YAML from 'yaml';
import { ShellExecutor } from '../ShellExecutor';
import { Logger } from '../Logger';
import axios, { AxiosResponse } from 'axios';

@injectable()
export class GitUtil {
Expand All @@ -33,9 +33,10 @@ export class GitUtil {
* @param linkToMetaYaml raw url to git repository where meta.yaml is;
* @return git link which uses in DevWorkspaceConfigurationHelper as DevfileUrl parameter
*/
static getProjectGitLinkFromLinkToMetaYaml(linkToMetaYaml: string): string {
static async getProjectGitLinkFromLinkToMetaYaml(linkToMetaYaml: string): Promise<string> {
Logger.debug(`${this.constructor.name}.${this.getProjectGitLinkFromLinkToMetaYaml.name} - ${linkToMetaYaml}`);
const metaYamlContent: any = YAML.parse(ShellExecutor.curl(linkToMetaYaml).stdout);
const response: AxiosResponse = await axios.get(linkToMetaYaml);
const metaYamlContent: any = YAML.parse(response.data);
Logger.debug(`${this.constructor.name}.${this.getProjectGitLinkFromLinkToMetaYaml.name} - ${metaYamlContent.links.v2}`);
return metaYamlContent.links.v2;
}
Expand Down

0 comments on commit 8aa6599

Please sign in to comment.