Skip to content

Commit

Permalink
Fix outdated test
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoldevila committed Oct 22, 2024
1 parent 7a0325e commit fe868fe
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('updateSourceMappingsProperties', () => {
appMappings: {
properties: {
a: { type: 'keyword' },
b: { type: 'long' },
c: { type: 'long' },
...getBaseMappings().properties,
},
Expand All @@ -68,8 +69,10 @@ describe('updateSourceMappingsProperties', () => {
it('should not update mappings when there are no changes', async () => {
// we overwrite the app mappings to have the "unchanged" values with respect to the index mappings
const sameMappingsParams = chain(params)
// let's not introduce 'c' for now
.set('indexTypes', ['a', 'b'])
// even if the app versions are more recent, we emulate a scenario where mappings haven NOT changed
.set('latestMappingsVersions', { a: '10.1.0', b: '10.1.0', c: '10.1.0' })
.set('latestMappingsVersions', { a: '10.1.0', b: '10.1.0' })
.value();
const result = await updateSourceMappingsProperties(sameMappingsParams)();

Expand All @@ -78,6 +81,28 @@ describe('updateSourceMappingsProperties', () => {
expect(result).toHaveProperty('right', 'update_mappings_succeeded');
});

it('should update mappings if there are new types', async () => {
// we overwrite the app mappings to have the "unchanged" values with respect to the index mappings
const sameMappingsParams = chain(params)
// even if the app versions are more recent, we emulate a scenario where mappings haven NOT changed
.set('latestMappingsVersions', { a: '10.1.0', b: '10.1.0', c: '10.1.0' })
.value();
const result = await updateSourceMappingsProperties(sameMappingsParams)();

expect(client.indices.putMapping).toHaveBeenCalledTimes(1);
expect(client.indices.putMapping).toHaveBeenCalledWith(
expect.objectContaining({
properties: expect.objectContaining({
a: { type: 'keyword' },
b: { type: 'long' },
c: { type: 'long' },
}),
})
);
expect(Either.isRight(result)).toEqual(true);
expect(result).toHaveProperty('right', 'update_mappings_succeeded');
});

it('should return that mappings are updated when changes are compatible', async () => {
const result = await updateSourceMappingsProperties(params)();

Expand Down

0 comments on commit fe868fe

Please sign in to comment.