-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Backwards compatibility with v1 config (#160)
* ✨ Add extensible config migration * 🔥 Remove migration logic from config:migrate * ✨ Handle own snapshot config migration logic * ✨ Handle own upload config migration logic * ✅ Move core queue tests to unit directory * ✨ Handle own core config migration logic
- Loading branch information
Wil Wilsman
authored
Feb 2, 2021
1 parent
19f0d05
commit 4eca80b
Showing
20 changed files
with
371 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import PercyConfig from '@percy/config'; | ||
import { schema } from '../config'; | ||
import { schema, migration } from '../config'; | ||
|
||
export default function() { | ||
PercyConfig.addSchema(schema); | ||
PercyConfig.addMigration(migration); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import expect from 'expect'; | ||
import { migration } from '../../src/config'; | ||
|
||
describe('unit / config', () => { | ||
let migrate; | ||
let set = (key, value) => (migrate[key] = value); | ||
|
||
beforeEach(() => { | ||
migrate = {}; | ||
}); | ||
|
||
it('migrates v1 config', () => { | ||
migration({ | ||
version: 1, | ||
staticSnapshots: { | ||
baseUrl: 'base-url', | ||
snapshotFiles: '*.html', | ||
ignoreFiles: '*.htm' | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({ | ||
'static.baseUrl': 'base-url', | ||
'static.files': '*.html', | ||
'static.ignore': '*.htm' | ||
}); | ||
}); | ||
|
||
it('only migrates own config options', () => { | ||
migration({ | ||
version: 1, | ||
otherOptions: { | ||
baseUrl: 'base-url', | ||
snapshotFiles: '*.html', | ||
ignoreFiles: '*.htm' | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({}); | ||
}); | ||
|
||
it('does not migrate when not needed', () => { | ||
migration({ | ||
version: 2, | ||
static: { | ||
baseUrl: 'base-url', | ||
files: '*.html', | ||
ignore: '*.htm' | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import PercyConfig from '@percy/config'; | ||
import { schema } from '../config'; | ||
import { schema, migration } from '../config'; | ||
|
||
export default function() { | ||
PercyConfig.addSchema(schema); | ||
PercyConfig.addMigration(migration); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import expect from 'expect'; | ||
import { migration } from '../../src/config'; | ||
|
||
describe('unit / config', () => { | ||
let migrate; | ||
let set = (key, value) => (migrate[key] = value); | ||
|
||
beforeEach(() => { | ||
migrate = {}; | ||
}); | ||
|
||
it('migrates v1 config', () => { | ||
migration({ | ||
version: 1, | ||
imageSnapshots: { | ||
path: '~/pathname/', | ||
files: '*.png', | ||
ignore: '*.jpg' | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({ | ||
'upload.files': '*.png', | ||
'upload.ignore': '*.jpg' | ||
}); | ||
}); | ||
|
||
it('only migrates own config options', () => { | ||
migration({ | ||
version: 1, | ||
otherOptions: { | ||
path: '~/pathname/', | ||
files: '*.png', | ||
ignore: '*.jpg' | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({}); | ||
}); | ||
|
||
it('does not migrate when not needed', () => { | ||
migration({ | ||
version: 2, | ||
upload: { | ||
files: '*.png', | ||
ignore: '*.jpg' | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.