Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

feat: Mock of Serverless object for unit tests #144

Merged
merged 3 commits into from
May 23, 2019

Conversation

tbarlow12
Copy link
Contributor

No description provided.

Copy link
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some feedback - let's discuss if not clear before merging.

import PluginManager = require('serverless/classes/PluginManager');

export class MockFactory {
public static createTestServerless(service?: Service, utils?: Utils, pluginManager?: PluginManager): Serverless {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see a use case where we would want to manually create utils or pluginManager? I would expect if we wanted to mock any of those calls we would just spy/mock on them after instantiation.

}
}

public static createTestPluginManager(): PluginManager {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change these to private if we don't expect to use them directly.


export class MockFactory {
public static createTestServerless(service?: Service, utils?: Utils, pluginManager?: PluginManager): Serverless {
const sls = new Serverless();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should expose the serverless config param in this mock factory that gets passed into Serverless ctor.

@tbarlow12 tbarlow12 merged commit 5cb2f5a into serverless:dev May 23, 2019
mydiemho pushed a commit that referenced this pull request May 24, 2019
tbarlow12 added a commit that referenced this pull request Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants