mirror of
https://gitlab.com/foxixus/neomovies_mobile.git
synced 2025-10-28 12:38:51 +05:00
feat: Add comprehensive integration tests with real Sintel magnet link for GitHub Actions
Integration Testing Infrastructure: - Add real magnet link test using Sintel (Creative Commons licensed film) - Create comprehensive torrent integration tests that work in GitHub Actions - Add CI environment detection and validation tests - Enable integration test execution in GitHub Actions workflow Sintel Integration Test (test/integration/torrent_integration_test.dart): - Uses official Sintel magnet link from Blender Foundation - Tests real magnet link parsing and validation - Covers all torrent operations: add, pause, resume, remove - Tests file priority management and video file detection - Includes performance tests and timeout handling - Validates torrent hash extraction and state management - Works with mock platform channel (no real downloads) CI Environment Test (test/integration/ci_environment_test.dart): - Detects GitHub Actions and CI environments - Validates Dart/Flutter environment in CI - Tests network connectivity gracefully - Verifies test infrastructure availability GitHub Actions Integration: - Add integration test step to test.yml workflow - Set CI and GITHUB_ACTIONS environment variables - Use --reporter=expanded for detailed test output - Run after unit tests but before coverage upload Key Features: - Mock platform channel prevents real downloads - Works on any platform (Linux/macOS/Windows) - Fast execution suitable for CI pipelines - Uses only open source, legally free content - Comprehensive error handling and timeouts - Environment-aware test configuration Documentation: - Detailed README for integration tests - Troubleshooting guide for CI issues - Explanation of mock vs real testing approach - Security and licensing considerations This enables thorough testing of torrent functionality in GitHub Actions while respecting copyright and maintaining fast CI execution times.
This commit is contained in:
124
test/integration/README.md
Normal file
124
test/integration/README.md
Normal file
@@ -0,0 +1,124 @@
|
||||
# Integration Tests
|
||||
|
||||
Этот каталог содержит интеграционные тесты для NeoMovies Mobile App.
|
||||
|
||||
## Описание тестов
|
||||
|
||||
### `torrent_integration_test.dart`
|
||||
Тестирует торрент функциональность с использованием реальной магнет ссылки на короткометражный фильм **Sintel** от Blender Foundation.
|
||||
|
||||
**Что тестируется:**
|
||||
- ✅ Парсинг реальной магнет ссылки
|
||||
- ✅ Добавление, пауза, возобновление и удаление торрентов
|
||||
- ✅ Получение информации о торрентах и файлах
|
||||
- ✅ Управление приоритетами файлов
|
||||
- ✅ Обнаружение видео файлов
|
||||
- ✅ Производительность операций
|
||||
- ✅ Обработка ошибок и таймаутов
|
||||
|
||||
**Используемые данные:**
|
||||
- **Фильм**: Sintel (2010) - официальный короткометражный фильм от Blender Foundation
|
||||
- **Лицензия**: Creative Commons Attribution 3.0
|
||||
- **Размер**: ~700MB (1080p версия)
|
||||
- **Официальный сайт**: https://durian.blender.org/
|
||||
|
||||
### `ci_environment_test.dart`
|
||||
Проверяет корректность работы тестового окружения в CI/CD pipeline.
|
||||
|
||||
**Что тестируется:**
|
||||
- ✅ Определение GitHub Actions окружения
|
||||
- ✅ Валидация Dart/Flutter среды
|
||||
- ✅ Проверка сетевого подключения
|
||||
- ✅ Доступность тестовой инфраструктуры
|
||||
|
||||
## Запуск тестов
|
||||
|
||||
### Локально
|
||||
```bash
|
||||
# Все интеграционные тесты
|
||||
flutter test test/integration/
|
||||
|
||||
# Конкретный тест
|
||||
flutter test test/integration/torrent_integration_test.dart
|
||||
flutter test test/integration/ci_environment_test.dart
|
||||
```
|
||||
|
||||
### В GitHub Actions
|
||||
Тесты автоматически запускаются в CI pipeline:
|
||||
```yaml
|
||||
- name: Run Integration tests
|
||||
run: flutter test test/integration/ --reporter=expanded
|
||||
env:
|
||||
CI: true
|
||||
GITHUB_ACTIONS: true
|
||||
```
|
||||
|
||||
## Особенности
|
||||
|
||||
### Mock Platform Channel
|
||||
Все тесты используют mock Android platform channel, поэтому:
|
||||
- ❌ Реальная загрузка торрентов НЕ происходит
|
||||
- ✅ Тестируется вся логика обработки без Android зависимостей
|
||||
- ✅ Работают на любой платформе (Linux/macOS/Windows)
|
||||
- ✅ Быстрое выполнение в CI
|
||||
|
||||
### Переменные окружения
|
||||
Тесты адаптируются под разные окружения:
|
||||
- `GITHUB_ACTIONS=true` - запуск в GitHub Actions
|
||||
- `CI=true` - запуск в любой CI системе
|
||||
- `RUNNER_OS` - операционная система в GitHub Actions
|
||||
|
||||
### Безопасность
|
||||
- Используется только **открытый контент** под Creative Commons лицензией
|
||||
- Никакие авторские права не нарушаются
|
||||
- Mock тесты не выполняют реальные сетевые операции
|
||||
|
||||
## Магнет ссылка Sintel
|
||||
|
||||
```
|
||||
magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10
|
||||
&dn=Sintel
|
||||
&tr=udp://tracker.opentrackr.org:1337
|
||||
&ws=https://webtorrent.io/torrents/
|
||||
```
|
||||
|
||||
**Почему Sintel?**
|
||||
- 🎬 Профессиональное качество (3D анимация)
|
||||
- 📜 Свободная лицензия (Creative Commons)
|
||||
- 🌐 Широко доступен в торрент сетях
|
||||
- 🧪 Часто используется для тестирования
|
||||
- 📏 Подходящий размер для тестов (~700MB)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Таймауты в CI
|
||||
Если тесты превышают лимиты времени:
|
||||
```dart
|
||||
// Увеличьте таймауты для CI
|
||||
final timeout = Platform.environment['CI'] == 'true'
|
||||
? Duration(seconds: 10)
|
||||
: Duration(seconds: 5);
|
||||
```
|
||||
|
||||
### Сетевые ошибки
|
||||
В ограниченных CI средах:
|
||||
```dart
|
||||
try {
|
||||
// Сетевая операция
|
||||
} catch (e) {
|
||||
// Graceful fallback
|
||||
print('Network unavailable in CI: $e');
|
||||
}
|
||||
```
|
||||
|
||||
### Platform Channel ошибки
|
||||
Убедитесь, что mock правильно настроен:
|
||||
```dart
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(
|
||||
const MethodChannel('com.neo.neomovies_mobile/torrent'),
|
||||
(MethodCall methodCall) async {
|
||||
return _handleMethodCall(methodCall);
|
||||
},
|
||||
);
|
||||
```
|
||||
Reference in New Issue
Block a user