mirror of
https://github.com/ivuorinen/actions.git
synced 2026-01-26 11:34:00 +00:00
* docs: update documentation * feat: validate-inputs has it's own pyproject * security: mask DOCKERHUB_PASSWORD * chore: add tokens, checkout, recrete docs, integration tests * fix: add `statuses: write` permission to pr-lint
75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
"""Tests for set-git-config custom validator.
|
|
|
|
Generated by generate-tests.py - Do not edit manually.
|
|
"""
|
|
# pylint: disable=invalid-name # Test file name matches action name
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add action directory to path to import custom validator
|
|
action_path = Path(__file__).parent.parent.parent / "set-git-config"
|
|
sys.path.insert(0, str(action_path))
|
|
|
|
# pylint: disable=wrong-import-position
|
|
from CustomValidator import CustomValidator
|
|
|
|
|
|
class TestCustomSetGitConfigValidator:
|
|
"""Test cases for set-git-config custom validator."""
|
|
|
|
def setup_method(self):
|
|
"""Set up test fixtures."""
|
|
self.validator = CustomValidator("set-git-config")
|
|
|
|
def teardown_method(self):
|
|
"""Clean up after tests."""
|
|
self.validator.clear_errors()
|
|
|
|
def test_validate_inputs_valid(self):
|
|
"""Test validation with valid inputs."""
|
|
# TODO: Add specific valid inputs for set-git-config
|
|
inputs = {}
|
|
result = self.validator.validate_inputs(inputs)
|
|
# Adjust assertion based on required inputs
|
|
assert isinstance(result, bool)
|
|
|
|
def test_validate_inputs_invalid(self):
|
|
"""Test validation with invalid inputs."""
|
|
# TODO: Add specific invalid inputs for set-git-config
|
|
inputs = {"invalid_key": "invalid_value"}
|
|
result = self.validator.validate_inputs(inputs)
|
|
# Custom validators may have specific validation rules
|
|
assert isinstance(result, bool)
|
|
|
|
def test_required_inputs(self):
|
|
"""Test required inputs detection."""
|
|
required = self.validator.get_required_inputs()
|
|
assert isinstance(required, list)
|
|
# TODO: Assert specific required inputs for set-git-config
|
|
|
|
def test_validation_rules(self):
|
|
"""Test validation rules."""
|
|
rules = self.validator.get_validation_rules()
|
|
assert isinstance(rules, dict)
|
|
# TODO: Assert specific validation rules for set-git-config
|
|
|
|
def test_github_expressions(self):
|
|
"""Test GitHub expression handling."""
|
|
inputs = {
|
|
"test_input": "${{ github.token }}",
|
|
}
|
|
result = self.validator.validate_inputs(inputs)
|
|
assert isinstance(result, bool)
|
|
# GitHub expressions should generally be accepted
|
|
|
|
def test_error_propagation(self):
|
|
"""Test error propagation from sub-validators."""
|
|
# Custom validators often use sub-validators
|
|
# Test that errors are properly propagated
|
|
inputs = {"test": "value"}
|
|
self.validator.validate_inputs(inputs)
|
|
# Check error handling
|
|
if self.validator.has_errors():
|
|
assert len(self.validator.errors) > 0
|