-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_finder.py
More file actions
75 lines (59 loc) · 2.37 KB
/
test_finder.py
File metadata and controls
75 lines (59 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
"""
Test script for the Integrations Finder tool.
"""
from integrations_finder import IntegrationsFinder
def test_sha_extraction():
"""Test SHA extraction from various input formats."""
finder = IntegrationsFinder()
test_cases = [
("a1b2c3d4", "a1b2c3d4"),
("stackstate/agent:7.51.1-a1b2c3d4", "a1b2c3d4"),
("registry.example.com/stackstate/agent:7.51.1-a1b2c3d4", "a1b2c3d4"),
("quay.io/stackstate/stackstate-k8s-agent:a1b2c3d4", "a1b2c3d4"),
("some-text-a1b2c3d4-more-text", "a1b2c3d4"),
("invalid-input", None),
("", None),
]
print("Testing SHA extraction:")
for input_str, expected in test_cases:
result = finder.extract_sha(input_str)
status = "✓" if result == expected else "✗"
print(f" {status} '{input_str}' -> '{result}' (expected: '{expected}')")
def test_integrations_finder():
"""Test the complete integrations finder workflow."""
finder = IntegrationsFinder()
# Test with a sample input (this will fail if the SHA doesn't exist)
test_input = "a1b2c3d4" # This is a dummy SHA for testing
print(f"\nTesting complete workflow with: {test_input}")
result = finder.find_integrations(test_input)
if len(result) == 3:
success, message, is_branch = result
print(f"Success: {success}")
print(f"Is Branch: {is_branch}")
print(f"Message: {message}")
else:
success, message = result
print(f"Success: {success}")
print(f"Message: {message}")
def test_branch_detection():
"""Test branch detection functionality."""
finder = IntegrationsFinder()
# Test known tags
known_tags = ["7.51.1-3", "7.51.1", "v1.0.0"]
print("\nTesting branch detection with known tags:")
for tag in known_tags:
is_branch = finder.is_branch_version(tag)
status = "BRANCH" if is_branch else "TAG"
print(f" {tag}: {status}")
# Test likely branches
likely_branches = ["main", "master", "develop", "feature-branch"]
print("\nTesting branch detection with likely branches:")
for branch in likely_branches:
is_branch = finder.is_branch_version(branch)
status = "BRANCH" if is_branch else "TAG"
print(f" {branch}: {status}")
if __name__ == "__main__":
test_sha_extraction()
test_integrations_finder()
test_branch_detection()