Skip to content

Commit

Permalink
Merge pull request #600 from project-violet/fix-tests
Browse files Browse the repository at this point in the history
Fix flutter tests
  • Loading branch information
violet-dev authored Dec 30, 2024
2 parents 90dba6d + 52e10f8 commit 0c8cd96
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/violet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
test:
if: ${{ github.event.label.name == 'ci/flutter-test' }}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
defaults:
run:
working-directory: violet
Expand Down
13 changes: 10 additions & 3 deletions violet/test/api_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This source code is a part of Project Violet.
// Copyright (C) 2020-2024. violet-team. Licensed under the Apache-2.0 License.

import 'dart:io';

import 'package:flutter_test/flutter_test.dart';
import 'package:violet/api/api.swagger.dart';
import 'package:violet/server/violet_v2.dart';
Expand All @@ -16,16 +18,21 @@ class MockApi {
}
}

void main() {
void main() async {
var disabled = true;
if (Platform.environment.containsKey('ENABLE_API_TESTS')) {
disabled = false;
}

MockApi.init();

test('Test Hello', () async {
final res = await MockApi.instance.apiV2Get();
expect(res.body as String, 'Hello World!');
});
}, skip: disabled);

test('Test Hmac', () async {
final res = await MockApi.instance.apiV2HmacGet();
expect(res.statusCode, 200);
});
}, skip: disabled);
}
14 changes: 5 additions & 9 deletions violet/test/component_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,25 @@ void main() {
WidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues({
'eh_cookies':
'yay=louder; ipb_member_id=2742770; ipb_pass_hash=622fcc2be82c922135bb0516e0ee497d; sl=dm_2; sk=t8inbzaqn45ttyn9f78eanzuqizh; igneous=hez0uu1qwsa7r91eqpt sl=dm_1'
'ipb_member_id=2742770; ipb_pass_hash=622fcc2be82c922135bb0516e0ee497d; sk=t8inbzaqn45ttyn9f78eanzuqizh; igneous=rcrmcztqgf1v8p1e0'
});
});

test('EHentai Gallery Parse', () async {
Settings.searchCategory = 1;
Settings.searchExpunged = false;
Settings.ignoreTimeout = true;
Settings.includeTagNetwork = false;
Settings.excludeTagNetwork = false;
});

test('EHentai Gallery Parse', () async {
final result =
await HentaiManager.searchEHentai('"female:big breasts"', 0, false);

expect(result.length >= 25, true);
});

test('ExHentai Gallery Parse', () async {
Settings.searchCategory = 1;
Settings.searchExpunged = false;
Settings.ignoreTimeout = true;

final result =
await HentaiManager.searchEHentai('"female:big breasts"', 0, true);

expect(result.length >= 25, true);
});

Expand Down
2 changes: 1 addition & 1 deletion violet/test/parse_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
Uri.parse('https://exhentai.org/g/2504057/6757b3c4b8/'),
headers: {
'Cookie':
'yay=louder; ipb_member_id=2742770; ipb_pass_hash=622fcc2be82c922135bb0516e0ee497d; ipb_session_id=8c457abd02a2ee708e532d7ba379a186; igneous=19f996fc4; sl=dm_1; sk=t8inbzaqn45ttyn9f78eanzuqizh'
'ipb_member_id=2742770; ipb_pass_hash=622fcc2be82c922135bb0516e0ee497d; sk=t8inbzaqn45ttyn9f78eanzuqizh; igneous=rcrmcztqgf1v8p1e0'
}))
.body;

Expand Down

0 comments on commit 0c8cd96

Please sign in to comment.