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

test has false positive as it does not check if the processed message doesn't contain the deleted message #15

Open
CForrest97 opened this issue Aug 28, 2019 · 0 comments
Labels

Comments

@CForrest97
Copy link

In the test in file src/api/rest/tests/MQRestClient.unit.test.ts

describe("ZosmfRestClient tests", () => {
    it("should delete stack from any zosmf errors before presenting them to users", () => {
        const zosmfRestClient = new MQRestClient(new Session({hostname: "dummy"}));
        const shouldNotDeleteMessage = "This should not be deleted";
        const shouldDeleteMessage = "This should be deleted";
        const error: IImperativeError = {
            msg: "hello",
            causeErrors: JSON.stringify({
                stack: shouldDeleteMessage,
                shouldNotDelete: shouldNotDeleteMessage
            })
        };
        const processedError = ((zosmfRestClient as any).processError(error));
        expect(processedError.msg).toContain(shouldNotDeleteMessage);
        expect(processedError.msg.indexOf()).toEqual(-1);

    });
});

the line expect(processedError.msg.indexOf()).toEqual(-1); doesnt actually check the message has been deleted, it just happens that the default behaviour is to return -1

potential fix: expect(processedError.msg.indexOf(shouldDeleteMessage)).toEqual(-1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Low Priority
Development

No branches or pull requests

2 participants