mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-01-06 01:20:32 +05:30
Merge pull request #519 from XiangRongLin/better_logging_error_handling
Better logging, error handling, doc for mock tests
This commit is contained in:
commit
a28e0226c5
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -32,7 +32,9 @@ jobs:
|
|||||||
- name: Build and run Tests
|
- name: Build and run Tests
|
||||||
run: |
|
run: |
|
||||||
if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
|
if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then
|
||||||
|
echo running with real downloader
|
||||||
./gradlew check --stacktrace -Ddownloader=REAL
|
./gradlew check --stacktrace -Ddownloader=REAL
|
||||||
else
|
else
|
||||||
|
echo running with mock downloader
|
||||||
./gradlew check --stacktrace -Ddownloader=MOCK
|
./gradlew check --stacktrace -Ddownloader=MOCK
|
||||||
fi
|
fi
|
||||||
|
@ -27,15 +27,17 @@ class MockDownloader extends Downloader {
|
|||||||
public MockDownloader(@Nonnull String path) throws IOException {
|
public MockDownloader(@Nonnull String path) throws IOException {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.mocks = new HashMap<>();
|
this.mocks = new HashMap<>();
|
||||||
File folder = new File(path);
|
final File[] files = new File(path).listFiles();
|
||||||
for (File file : folder.listFiles()) {
|
if (files != null) {
|
||||||
if (file.getName().startsWith(RecordingDownloader.FILE_NAME_PREFIX)) {
|
for (File file : files) {
|
||||||
final FileReader reader = new FileReader(file);
|
if (file.getName().startsWith(RecordingDownloader.FILE_NAME_PREFIX)) {
|
||||||
final TestRequestResponse response = new GsonBuilder()
|
final FileReader reader = new FileReader(file);
|
||||||
.create()
|
final TestRequestResponse response = new GsonBuilder()
|
||||||
.fromJson(reader, TestRequestResponse.class);
|
.create()
|
||||||
reader.close();
|
.fromJson(reader, TestRequestResponse.class);
|
||||||
mocks.put(response.getRequest(), response.getResponse());
|
reader.close();
|
||||||
|
mocks.put(response.getRequest(), response.getResponse());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,10 @@ import javax.annotation.Nonnull;
|
|||||||
* The files <b>must</b> be created on the local dev environment
|
* The files <b>must</b> be created on the local dev environment
|
||||||
* and recreated when the requests made by a test class change.
|
* and recreated when the requests made by a test class change.
|
||||||
* </p>
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* Run the test class as a whole and not each test separately.
|
||||||
|
* Make sure the requests made by a class are unique.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
class RecordingDownloader extends Downloader {
|
class RecordingDownloader extends Downloader {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user