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

Added mocks and logging #24743

Merged
merged 2 commits into from
Oct 29, 2018

Conversation

FrankHassanabad
Copy link
Contributor

Added mocks and logging

  * https://github.com/elastic/ingest-dev/issues/54
  * Added test mocks to GraphQL
  * Added logging
  * Added unit tests
@FrankHassanabad
Copy link
Contributor Author

For testing the mocks:

export INGEST_MOCKS=true
yarn start --no-base-path

Go here:

http://localhost:5601/api/secops/graphql/graphiql

Add this to your GraphIQ to trigger the mock test:

query test {
  source(id: "default") {
    id,
    configuration {
      fields {
        host
      }
    }
  }
}

Add this to your GraphIq to trigger the mock test for allSources

query test {
  allSources {
    id,configuration {
      fields {
        container,
        host,
        message,        
      }
    }
  }
}

@elasticmachine
Copy link
Contributor

💔 Build Failed

@FrankHassanabad
Copy link
Contributor Author

retest

@XavierM
Copy link
Contributor

XavierM commented Oct 29, 2018

I think that it is failling because you declare const createMockServer = () => ({ log: jest.fn() }); and never used it in this file x-pack/plugins/secops/server/kibana.index.test.ts

@elasticmachine
Copy link
Contributor

💔 Build Failed


import { amMocking } from './kibana.index';

const createMockServer = () => ({ log: jest.fn() });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dead variable causing build to fail.

describe('#createLogger', () => {
test('should log out debug', () => {
const kbnServer = createMockServer();
const logger = createLogger(kbnServer as any);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think in the logger one, I should follow the no any advice even with tests where possible. I have a lot of:

const logger = createLogger(kbnServer as any);

I think I can change the logger interface to only use the hapi Logger interface instead of pushing the whole Kibana Server in. Let me try that and see what happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created issue for this per conversation to keep things moving forward quickly:
https://github.com/elastic/ingest-dev/issues/73

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@XavierM XavierM merged commit 820d0c5 into elastic:feature-secops Oct 29, 2018
@FrankHassanabad FrankHassanabad deleted the add-mocks-and-logger branch October 29, 2018 16:56
@FrankHassanabad FrankHassanabad added the loe:small Small Level of Effort label Oct 30, 2018
andrew-goldstein pushed a commit that referenced this pull request Dec 4, 2018
* Added mocks and logging
  * https://github.com/elastic/ingest-dev/issues/54
  * Added test mocks to GraphQL
  * Added logging
  * Added unit tests

* Removed dead variable causing the build to fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
loe:small Small Level of Effort review Team:SIEM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants