Skip to content
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

fix(core-cli): check total memory only #4503

Merged
merged 3 commits into from
Sep 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix tests
  • Loading branch information
rainydio committed Sep 21, 2021
commit c0bc34e0f5e5f9453ec1446b44f7715e20192a8c
20 changes: 1 addition & 19 deletions __tests__/unit/core-cli/actions/daemonize-process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ describe("DaemonizeProcess", () => {
const has = jest.spyOn(processManager, "has").mockReturnValue(true);
const isUnknown = jest.spyOn(processManager, "isUnknown").mockReturnValue(false);
const isOnline = jest.spyOn(processManager, "isOnline").mockReturnValue(false);
const freemem = jest.spyOn(os, "freemem").mockReturnValue(99999999999);
const totalmem = jest.spyOn(os, "totalmem").mockReturnValue(99999999999);
const start = jest.spyOn(processManager, "start").mockImplementation(undefined);

Expand All @@ -107,7 +106,6 @@ describe("DaemonizeProcess", () => {
expect(has).toHaveBeenCalledWith("ark-core");
expect(isUnknown).toHaveBeenCalledWith("ark-core");
expect(isOnline).toHaveBeenCalledWith("ark-core");
expect(freemem).toHaveBeenCalled();
expect(totalmem).toHaveBeenCalled();
expect(start).toHaveBeenCalledWith(
{
Expand All @@ -123,7 +121,6 @@ describe("DaemonizeProcess", () => {
has.mockClear();
isUnknown.mockClear();
isOnline.mockClear();
freemem.mockClear();
totalmem.mockClear();
start.mockClear();
});
Expand All @@ -132,7 +129,6 @@ describe("DaemonizeProcess", () => {
const has = jest.spyOn(processManager, "has").mockReturnValue(true);
const isUnknown = jest.spyOn(processManager, "isUnknown").mockReturnValue(false);
const isOnline = jest.spyOn(processManager, "isOnline").mockReturnValue(false);
const freemem = jest.spyOn(os, "freemem").mockReturnValue(99999999999);
const totalmem = jest.spyOn(os, "totalmem").mockReturnValue(99999999999);
const start = jest.spyOn(processManager, "start").mockImplementation(undefined);

Expand All @@ -148,7 +144,6 @@ describe("DaemonizeProcess", () => {
expect(has).toHaveBeenCalledWith("ark-core");
expect(isUnknown).toHaveBeenCalledWith("ark-core");
expect(isOnline).toHaveBeenCalledWith("ark-core");
expect(freemem).toHaveBeenCalled();
expect(totalmem).toHaveBeenCalled();
expect(start).toHaveBeenCalledWith(
{
Expand All @@ -164,7 +159,6 @@ describe("DaemonizeProcess", () => {
has.mockClear();
isUnknown.mockClear();
isOnline.mockClear();
freemem.mockClear();
totalmem.mockClear();
start.mockClear();
});
Expand All @@ -173,7 +167,6 @@ describe("DaemonizeProcess", () => {
const has = jest.spyOn(processManager, "has").mockReturnValue(true);
const isUnknown = jest.spyOn(processManager, "isUnknown").mockReturnValue(false);
const isOnline = jest.spyOn(processManager, "isOnline").mockReturnValue(false);
const freemem = jest.spyOn(os, "freemem").mockReturnValue(99999999999);
const totalmem = jest.spyOn(os, "totalmem").mockReturnValue(99999999999);
const start = jest.spyOn(processManager, "start").mockImplementation(undefined);

Expand All @@ -189,7 +182,6 @@ describe("DaemonizeProcess", () => {
expect(has).toHaveBeenCalledWith("ark-core");
expect(isUnknown).toHaveBeenCalledWith("ark-core");
expect(isOnline).toHaveBeenCalledWith("ark-core");
expect(freemem).toHaveBeenCalled();
expect(totalmem).toHaveBeenCalled();
expect(start).toHaveBeenCalledWith(
{
Expand All @@ -205,7 +197,6 @@ describe("DaemonizeProcess", () => {
has.mockClear();
isUnknown.mockClear();
isOnline.mockClear();
freemem.mockClear();
totalmem.mockClear();
start.mockClear();
});
Expand All @@ -214,8 +205,7 @@ describe("DaemonizeProcess", () => {
const has = jest.spyOn(processManager, "has").mockReturnValue(true);
const isUnknown = jest.spyOn(processManager, "isUnknown").mockReturnValue(false);
const isOnline = jest.spyOn(processManager, "isOnline").mockReturnValue(false);
const freemem = jest.spyOn(os, "freemem").mockReturnValue(1);
const totalmem = jest.spyOn(os, "totalmem").mockReturnValue(1);
const totalmem = jest.spyOn(os, "totalmem").mockReturnValue(2 * 1024 ** 3 - 1);
const start = jest.spyOn(processManager, "start").mockImplementation(undefined);

action.execute(
Expand All @@ -230,7 +220,6 @@ describe("DaemonizeProcess", () => {
expect(has).toHaveBeenCalledWith("ark-core");
expect(isUnknown).toHaveBeenCalledWith("ark-core");
expect(isOnline).toHaveBeenCalledWith("ark-core");
expect(freemem).toHaveBeenCalled();
expect(totalmem).toHaveBeenCalled();
expect(start).toHaveBeenCalledWith(
{
Expand All @@ -251,7 +240,6 @@ describe("DaemonizeProcess", () => {
has.mockClear();
isUnknown.mockClear();
isOnline.mockClear();
freemem.mockClear();
totalmem.mockClear();
start.mockClear();
});
Expand All @@ -260,7 +248,6 @@ describe("DaemonizeProcess", () => {
const has = jest.spyOn(processManager, "has").mockReturnValue(true);
const isUnknown = jest.spyOn(processManager, "isUnknown").mockReturnValue(false);
const isOnline = jest.spyOn(processManager, "isOnline").mockReturnValue(false);
const freemem = jest.spyOn(os, "freemem").mockReturnValue(99999999999);
const totalmem = jest.spyOn(os, "totalmem").mockReturnValue(99999999999);
const start = jest.spyOn(processManager, "start").mockImplementation(() => {
throw new Error("unexpected error");
Expand All @@ -280,7 +267,6 @@ describe("DaemonizeProcess", () => {
expect(has).toHaveBeenCalledWith("ark-core");
expect(isUnknown).toHaveBeenCalledWith("ark-core");
expect(isOnline).toHaveBeenCalledWith("ark-core");
expect(freemem).toHaveBeenCalled();
expect(totalmem).toHaveBeenCalled();
expect(start).toHaveBeenCalledWith(
{
Expand All @@ -296,7 +282,6 @@ describe("DaemonizeProcess", () => {
has.mockClear();
isUnknown.mockClear();
isOnline.mockClear();
freemem.mockClear();
totalmem.mockClear();
start.mockClear();
});
Expand All @@ -305,7 +290,6 @@ describe("DaemonizeProcess", () => {
const has = jest.spyOn(processManager, "has").mockReturnValue(true);
const isUnknown = jest.spyOn(processManager, "isUnknown").mockReturnValue(false);
const isOnline = jest.spyOn(processManager, "isOnline").mockReturnValue(false);
const freemem = jest.spyOn(os, "freemem").mockReturnValue(99999999999);
const totalmem = jest.spyOn(os, "totalmem").mockReturnValue(99999999999);
const start = jest.spyOn(processManager, "start").mockImplementation(() => {
const error: Error = new Error("hello world");
Expand All @@ -329,7 +313,6 @@ describe("DaemonizeProcess", () => {
expect(has).toHaveBeenCalledWith("ark-core");
expect(isUnknown).toHaveBeenCalledWith("ark-core");
expect(isOnline).toHaveBeenCalledWith("ark-core");
expect(freemem).toHaveBeenCalled();
expect(totalmem).toHaveBeenCalled();
expect(start).toHaveBeenCalledWith(
{
Expand All @@ -345,7 +328,6 @@ describe("DaemonizeProcess", () => {
has.mockClear();
isUnknown.mockClear();
isOnline.mockClear();
freemem.mockClear();
totalmem.mockClear();
start.mockClear();
});
Expand Down