Skip to content

Commit

Permalink
fix: convert empty array literals to empty collection literals (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra authored Nov 16, 2020
1 parent 8c84d02 commit 7f42a11
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/components/Launch/LaunchForm/inputHelpers/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ function toLiteral({
return literalNone();
}
parsed = parseCollection(stringValue);
if (!parsed.length) {
return literalNone();
}
}

const helper = getHelperForInput(subtype.type);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { stringifyValue } from 'common/utils';
import { Core } from 'flyteidl';
import * as Long from 'long';
import { BlobDimensionality } from 'models';
import { BlobDimensionality, SimpleType } from 'models';
import {
collectionInputTypeDefinition,
nestedCollectionInputTypeDefinition,
Expand Down Expand Up @@ -207,6 +207,34 @@ describe('inputToLiteral', () => {
).toEqual(output);
});
});

it('should convert empty array string literal to empty collection', () => {
const input = makeCollectionInput(
{
type: InputType.String,
literalType: { simple: SimpleType.STRING }
},
'[]'
);
const expected: Core.ILiteral = {
collection: { literals: [] }
};
expect(inputToLiteral(input)).toEqual(expected);
});

it('should convert nested empty array string literal to nested empty collection', () => {
const input = makeNestedCollectionInput(
{
type: InputType.String,
literalType: { simple: SimpleType.STRING }
},
'[[]]'
);
const expected: Core.ILiteral = {
collection: { literals: [{ collection: { literals: [] } }] }
};
expect(inputToLiteral(input)).toEqual(expected);
});
});

describe('Unsupported Types', () => {
Expand Down

0 comments on commit 7f42a11

Please sign in to comment.