Skip to content

Commit

Permalink
Merge pull request openshift#11831 from invincibleJai/bz-2106803
Browse files Browse the repository at this point in the history
Bug 2106803: mock call to /api/devfile in e2e
  • Loading branch information
openshift-ci[bot] authored Jul 17, 2022
2 parents 8b1e48e + b9e7cc5 commit c212afa
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export const gitPage = {
statusCode: responses.packageResponse ? 200 : 404,
body: responses.packageResponse,
}).as('getPackage');

cy.intercept('POST', '/api/devfile/', {
statusCode: responses.devFileResources ? 200 : 404,
body: responses.devFileResources,
}).as('getDevfileResources');
}

cy.get(gitPO.gitRepoUrl)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"imageStream": {
"kind": "ImageStream",
"apiVersion": "image.openshift.io/v1",
"metadata": {},
"spec": {
"lookupPolicy": {
"local": false
}
},
"status": {
"dockerImageRepository": ""
}
},
"buildResource": {
"kind": "BuildConfig",
"apiVersion": "build.openshift.io/v1",
"metadata": {},
"spec": {
"source": {
"type": "Git",
"git": {
"uri": "https://github.com/nodeshift-starters/devfile-sample"
},
"contextDir": "."
},
"strategy": {
"type": "Docker",
"dockerStrategy": {
"dockerfilePath": "Dockerfile"
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "devfile-sample:latest:latest"
}
},
"resources": {},
"postCommit": {},
"nodeSelector": null
},
"status": {
"lastVersion": 0
}
},
"deployResource": {
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {},
"spec": {
"selector": {
"matchLabels": {
"app": "devfile-sample"
}
},
"template": {
"metadata": {
"creationTimestamp": null
},
"spec": {
"containers": [
{
"name": "runtime",
"image": "registry.access.redhat.com/ubi8/nodejs-16:latest",
"ports": [
{
"name": "3000-tcp",
"containerPort": 3000,
"protocol": "TCP"
}
],
"env": [
{
"name": "PROJECTS_ROOT",
"value": "/projects"
},
{
"name": "PROJECT_SOURCE",
"value": "/projects"
}
],
"resources": {
"limits": {
"memory": "1Gi"
}
},
"imagePullPolicy": "Always"
}
]
}
},
"strategy": {
"type": "Recreate"
}
},
"status": {}
},
"service": {
"kind": "Service",
"apiVersion": "v1",
"metadata": {},
"spec": {
"ports": [
{
"name": "port-3000",
"port": 3000,
"targetPort": 3000
},
{
"name": "http-3001",
"port": 3001,
"targetPort": "3001"
}
]
},
"status": {
"loadBalancer": {}
}
},
"route": {
"kind": "Route",
"apiVersion": "route.openshift.io/v1",
"metadata": {},
"spec": {
"path": "/",
"to": {
"kind": "Service",
"name": "devfile-sample",
"weight": null
},
"port": {
"targetPort": "3001"
}
},
"status": {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ export function getResponseMocks(repo: GithubRepo) {
const contentsJson = require(`./${repo.folder}/contents.json`);

let packageJson = null;
let devFileResources = null;
try {
packageJson = require(`./${repo.folder}/package.json`);
} catch (err) {
// nothing, the file does not exist
}
return { repoResponse: repoJson, contentsResponse: contentsJson, packageResponse: packageJson };
try {
devFileResources = require(`./${repo.folder}/devFileResources.json`);
} catch (err) {
// nothing, the file does not exist
}
return {
repoResponse: repoJson,
contentsResponse: contentsJson,
packageResponse: packageJson,
devFileResources,
};
}

0 comments on commit c212afa

Please sign in to comment.