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

Increase test coverage #150

Merged
merged 2 commits into from
Mar 21, 2022
Merged

Increase test coverage #150

merged 2 commits into from
Mar 21, 2022

Conversation

andresmgot
Copy link
Contributor

Fixes #149

  • Added tests to appendFrames (and discovered a potential bug?)
  • Added tests to MetadataInspector (and migrated to a function component)
  • Removed unused component Forms

The coverage is now 47% which is not great but at least covers the 40% level that we wanted:

File                | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s       
--------------------|---------|----------|---------|---------|-------------------------
All files           |   47.78 |    33.58 |    58.9 |   46.61 |                         
 src                |   26.25 |     8.38 |   21.88 |    26.5 |                         
  DataSource.ts     |   17.86 |     6.04 |   22.73 |   18.25 | 34-55,75,95-326,333-340 
  appendFrames.ts   |   80.95 |       60 |     100 |   84.62 | 8,21,53,58-60           
  module.ts         |       0 |      100 |     100 |       0 | 1-8                     
  regions.ts        |     100 |      100 |     100 |     100 |                         
  requestLooper.ts  |     7.5 |        0 |       0 |     7.5 | 38-111                  
  types.ts          |       0 |        0 |       0 |       0 | 10-23                   
 src/components     |   90.83 |    86.05 |    87.8 |   91.43 |                         
  ConfigEditor.tsx  |   86.11 |    78.57 |   84.62 |   83.87 | 22-30,55-56             
  MetaInspector.tsx |   91.67 |    83.33 |     100 |   91.67 | 15                      
  QueryEditor.tsx   |      98 |     91.3 |   94.44 |   97.83 | 183                     
  Suggestions.tsx   |     100 |      100 |     100 |     100 |                         
  index.ts          |       0 |      100 |       0 |       0 | 1-2                     
  samples.ts        |     100 |      100 |     100 |     100 |                         
  selectors.ts      |     100 |      100 |     100 |     100 |                         
--------------------|---------|----------|---------|---------|-------------------------

@andresmgot andresmgot requested a review from a team as a code owner March 17, 2022 17:20
@andresmgot andresmgot requested review from fridgepoet and sarahzinger and removed request for a team March 17, 2022 17:20
Copy link
Member

@sarahzinger sarahzinger left a comment

Choose a reason for hiding this comment

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

Looks good to me!

expect(appendMatchingFrames([], [])).toEqual([]);
});

it('should return input MutableDataFrames', () => {
Copy link
Member

Choose a reason for hiding this comment

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

kind of a nit that we can ignore if we don't have good ideas for it:

  • in reading this test and the one below I'm not sure I really understand the difference between these two tests. I wonder if we can update the "it" statements to better describe what we're handling or something. Or if these some data frames are mutable should we change them and see that append still handles them the same or something?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about :

Suggested change
it('should return input MutableDataFrames', () => {
it('should return input when input is a MutableDataFrames array, () => {

and next suggestion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good to me

@@ -58,6 +58,8 @@ export function appendMatchingFrames(prev: DataFrame[], b: DataFrame[]): DataFra
for (let i = 0; i < f.length; i++) {
for (let idx = 0; idx < old.fields.length; idx++) {
old.fields[idx].values.add(f.fields[idx].values.get(i));
// FIXME: I assume this is meant to modify `out` but it's
// not doing anything atm
Copy link
Member

Choose a reason for hiding this comment

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

lol should we make a ticket or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

double checking this it actually works 🤯

I assume that old.fields[idx] is pointing to the same vector reference than out so modifying that modifies the result. I have added a test that covers this.

expect(appendMatchingFrames([frame], [])).toEqual([frame]);
});

it('should return input DataFrame', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('should return input DataFrame', () => {
it('should return a MutableDataFrame version of input when input is a DataFrames array', () => {


it('should append new frames', () => {
const frame = new MutableDataFrame({ fields: [{ name: 'foo', values: v }] });
expect(appendMatchingFrames([], [frame])).toEqual([frame]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a test for two not empty arrays?
Not sure the following works ;)

Suggested change
expect(appendMatchingFrames([], [frame])).toEqual([frame]);
expect(appendMatchingFrames([frame], [frame])).toEqual([frame, frame]);


import { DataSource } from '../DataSource';
import { TimestreamOptions, TimestreamQuery } from '../types';

export type Props = MetadataInspectorProps<DataSource, TimestreamQuery, TimestreamOptions>;

export class MetaInspector extends PureComponent<Props> {
state = { index: 0 };
export function MetaInspector(props: Props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@andresmgot andresmgot merged commit c63fdfb into main Mar 21, 2022
@andresmgot andresmgot deleted the timeStreamTests branch March 21, 2022 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increase unit-test coverage
3 participants