Forgejo-Client Deduplication: Add --dry-mode for Testing #11

Open
opened 2026-04-23 09:59:40 +02:00 by kade · 0 comments
Owner

Forgejo-Client Deduplication: Add --dry-mode for Testing

Overview

Add a --dry-mode flag to the duplicate_detection_alert.py script to enable comprehensive integration testing without requiring actual Forgejo connections. This allows testing all code paths (clean repository, duplicates found, connection errors) using mock data while maintaining CI/CD compatibility for production use.

Implementation Plan

Changes to duplicate_detection_alert.py

New Flag:

  • Add --dry-mode flag to argument parser
  • When --dry-mode is enabled, use mock data instead of actual API calls
  • Bypass connection testing and use pre-defined test scenarios

Mock Data Scenarios:

  1. Clean Repository: No duplicates, exit code 0
  2. Repository with Duplicates: Known duplicates, exit code 1
  3. Connection Error: Simulated connection failure, exit code 2

Integration Tests

Create comprehensive integration tests for --dry-mode:

  • Test clean repository scenario (exit code 0)
  • Test duplicate detection scenario (exit code 1)
  • Test connection error scenario (exit code 2)
  • Test JSON output with mock data
  • Test verbose output with mock data
  • Test custom thresholds with mock data

Benefits

  • No Infrastructure Required: Test without Forgejo instance or Docker setup
  • Fast Testing: Immediate feedback without network calls
  • CI/CD Compatible: Production behavior unchanged when --dry-mode is not used
  • Comprehensive Coverage: Test all error conditions and success paths
  • Safe: Cannot accidentally affect production data

Files to Modify

  • scripts/forgejo-client/duplicate_detection_alert.py - Add --dry-mode flag and mock data
  • scripts/forgejo-client/tests/test_duplicate_detection_alert.py - Add --dry-mode integration tests
  • #1032: Forgejo-Client Deduplication CI/CD Integration
  • #918: Forgejo-Client: Extend Deduplication System to Comments

Migrated from reynard/reynard#1044

# Forgejo-Client Deduplication: Add --dry-mode for Testing ## Overview Add a --dry-mode flag to the duplicate_detection_alert.py script to enable comprehensive integration testing without requiring actual Forgejo connections. This allows testing all code paths (clean repository, duplicates found, connection errors) using mock data while maintaining CI/CD compatibility for production use. ## Implementation Plan ### Changes to duplicate_detection_alert.py **New Flag:** - Add --dry-mode flag to argument parser - When --dry-mode is enabled, use mock data instead of actual API calls - Bypass connection testing and use pre-defined test scenarios **Mock Data Scenarios:** 1. **Clean Repository:** No duplicates, exit code 0 2. **Repository with Duplicates:** Known duplicates, exit code 1 3. **Connection Error:** Simulated connection failure, exit code 2 ### Integration Tests Create comprehensive integration tests for --dry-mode: - Test clean repository scenario (exit code 0) - Test duplicate detection scenario (exit code 1) - Test connection error scenario (exit code 2) - Test JSON output with mock data - Test verbose output with mock data - Test custom thresholds with mock data ### Benefits - **No Infrastructure Required:** Test without Forgejo instance or Docker setup - **Fast Testing:** Immediate feedback without network calls - **CI/CD Compatible:** Production behavior unchanged when --dry-mode is not used - **Comprehensive Coverage:** Test all error conditions and success paths - **Safe:** Cannot accidentally affect production data ## Files to Modify - `scripts/forgejo-client/duplicate_detection_alert.py` - Add --dry-mode flag and mock data - `scripts/forgejo-client/tests/test_duplicate_detection_alert.py` - Add --dry-mode integration tests ## Related Issues - #1032: Forgejo-Client Deduplication CI/CD Integration - #918: Forgejo-Client: Extend Deduplication System to Comments --- **Migrated from reynard/reynard#1044**
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kade/forgejo-client#11
No description provided.