Skip to content

Commit e0081e1

Browse files
committed
fix: tests
1 parent f540202 commit e0081e1

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

test/interactivePublishFlow.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import { fileURLToPath } from 'url'
77

88
const __filename = fileURLToPath(import.meta.url)
99
const __dirname = dirname(__filename)
10-
describe("Ocean CLI Interactive Publishing", function() {
10+
describe("Ocean CLI Interactive Publishing", function () {
1111
this.timeout(120000); // Set a longer timeout to allow for user input simulation
1212

1313
const projectRoot = path.resolve(__dirname, "..");
1414
let publishedDid: string;
1515

16-
it("should publish an asset using 'npm run cli start' interactive flow", function(done) {
16+
it("should publish an asset using 'npm run cli start' interactive flow", function (done) {
1717
process.env.PRIVATE_KEY = "0x1d751ded5a32226054cd2e71261039b65afb9ee1c746d055dd699b1150a5befc";
1818
process.env.RPC = "http://127.0.0.1:8545";
1919
process.env.NODE_URL = "http://127.0.0.1:8001";
@@ -43,7 +43,9 @@ describe("Ocean CLI Interactive Publishing", function() {
4343
if (child.stdin) {
4444
const inputInterval = setInterval(() => {
4545
if (inputIndex < inputs.length) {
46-
child.stdin.write(inputs[inputIndex]);
46+
if (child.stdin) {
47+
child.stdin.write(inputs[inputIndex]);
48+
}
4749
inputIndex++;
4850
} else {
4951
clearInterval(inputInterval);
@@ -61,7 +63,7 @@ describe("Ocean CLI Interactive Publishing", function() {
6163
expect(code).to.equal(0);
6264
expect(fullOutput).to.contain("Asset successfully published with DID:");
6365
expect(fullOutput).to.contain("Metadata successfully updated for DID:");
64-
66+
6567
const match = fullOutput.match(/did:op:[a-f0-9]{64}/);
6668
if (match) {
6769
publishedDid = match[0];
@@ -77,7 +79,7 @@ describe("Ocean CLI Interactive Publishing", function() {
7779
});
7880
});
7981

80-
it("should get DDO using 'npm run cli getDDO' for the published asset", function(done) {
82+
it("should get DDO using 'npm run cli getDDO' for the published asset", function (done) {
8183
exec(`npm run cli getDDO ${publishedDid}`, { cwd: projectRoot }, (error, stdout) => {
8284
try {
8385
expect(stdout).to.contain(`${publishedDid}`);

test/paidComputeFlow.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,21 @@ describe("Ocean CLI Paid Compute", function () {
152152
const env = computeEnvs[0];
153153
expect(env).to.be.an('object').and.to.not.be.null.and.to.not.be.undefined;
154154

155+
if (!env.resources || !Array.isArray(env.resources) || env.resources.length < 2) {
156+
throw new Error("Compute environment resources are not available or invalid.");
157+
}
155158
resources = [
156159
{
157160
id: 'cpu',
158-
amount: env.resources[0].max - env.resources[0].inUse - 1
161+
amount: env.resources[0]?.max !== undefined && env.resources[0]?.inUse !== undefined
162+
? env.resources[0].max - env.resources[0].inUse - 1
163+
: 0
159164
},
160165
{
161166
id: 'ram',
162-
amount: env.resources[1].max - env.resources[1].inUse - 1000
167+
amount: env.resources[1]?.max !== undefined && env.resources[1]?.inUse !== undefined
168+
? env.resources[1].max - env.resources[1].inUse - 1000
169+
: 0
163170
},
164171
{
165172
id: 'disk',

0 commit comments

Comments
 (0)