jekyll-theme-zer0 0.10.6 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +428 -0
- data/README.md +79 -31
- data/_data/README.md +419 -17
- data/_data/generate_statistics.rb +216 -9
- data/_data/generate_statistics.sh +106 -0
- data/_data/github-actions-example.yml +210 -0
- data/_data/navigation/about.yml +39 -11
- data/_data/navigation/docs.yml +53 -23
- data/_data/navigation/home.yml +27 -9
- data/_data/navigation/main.yml +27 -8
- data/_data/navigation/posts.yml +22 -6
- data/_data/navigation/quickstart.yml +19 -6
- data/_data/posts_organization.yml +153 -0
- data/_data/prerequisites.yml +112 -0
- data/_data/statistics_config.yml +203 -0
- data/_data/ui-text.yml +321 -0
- data/_data/update_statistics.sh +126 -0
- data/_includes/README.md +2 -0
- data/_includes/components/js-cdn.html +4 -1
- data/_includes/components/post-card.html +2 -11
- data/_includes/components/preview-image.html +32 -0
- data/_includes/content/intro.html +9 -10
- data/_includes/core/header.html +14 -0
- data/_includes/navigation/sidebar-categories.html +20 -9
- data/_includes/navigation/sidebar-folders.html +8 -7
- data/_includes/navigation/sidebar-right.html +16 -10
- data/_layouts/blog.html +15 -45
- data/_layouts/category.html +4 -24
- data/_layouts/collection.html +2 -12
- data/_layouts/default.html +1 -1
- data/_layouts/journals.html +2 -12
- data/_layouts/notebook.html +296 -0
- data/_sass/core/_docs.scss +1 -1
- data/_sass/custom.scss +54 -17
- data/_sass/notebooks.scss +458 -0
- data/assets/images/notebooks/test-notebook_files/test-notebook_4_0.png +0 -0
- data/assets/js/sidebar.js +511 -0
- data/scripts/README.md +131 -105
- data/scripts/analyze-commits.sh +9 -311
- data/scripts/bin/build +22 -22
- data/scripts/build +7 -111
- data/scripts/convert-notebooks.sh +415 -0
- data/scripts/features/validate_preview_urls.py +500 -0
- data/scripts/fix-markdown-format.sh +8 -262
- data/scripts/generate-preview-images.sh +7 -787
- data/scripts/install-preview-generator.sh +8 -528
- data/scripts/lib/README.md +5 -5
- data/scripts/lib/changelog.sh +89 -57
- data/scripts/lib/gem.sh +19 -7
- data/scripts/release +7 -236
- data/scripts/setup.sh +9 -153
- data/scripts/test/lib/run_tests.sh +1 -2
- data/scripts/test-auto-version.sh +7 -256
- data/scripts/test-mermaid.sh +7 -287
- data/scripts/test.sh +9 -154
- metadata +16 -10
- data/scripts/features/preview_generator.py +0 -646
- data/scripts/lib/test/run_tests.sh +0 -140
- data/scripts/lib/test/test_changelog.sh +0 -87
- data/scripts/lib/test/test_gem.sh +0 -68
- data/scripts/lib/test/test_git.sh +0 -82
- data/scripts/lib/test/test_validation.sh +0 -72
- data/scripts/lib/test/test_version.sh +0 -96
- data/scripts/version.sh +0 -178
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Test runner for library unit tests
|
|
4
|
-
# Usage: ./scripts/lib/test/run_tests.sh
|
|
5
|
-
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
9
|
-
LIB_DIR="$(dirname "$SCRIPT_DIR")"
|
|
10
|
-
|
|
11
|
-
# Colors
|
|
12
|
-
RED='\033[0;31m'
|
|
13
|
-
GREEN='\033[0;32m'
|
|
14
|
-
YELLOW='\033[1;33m'
|
|
15
|
-
BLUE='\033[0;34m'
|
|
16
|
-
NC='\033[0m'
|
|
17
|
-
|
|
18
|
-
# Test counters
|
|
19
|
-
TESTS_RUN=0
|
|
20
|
-
TESTS_PASSED=0
|
|
21
|
-
TESTS_FAILED=0
|
|
22
|
-
|
|
23
|
-
# Test result tracking
|
|
24
|
-
declare -a FAILED_TESTS=()
|
|
25
|
-
|
|
26
|
-
# Test assertions
|
|
27
|
-
assert_equals() {
|
|
28
|
-
local expected="$1"
|
|
29
|
-
local actual="$2"
|
|
30
|
-
local message="${3:-}"
|
|
31
|
-
|
|
32
|
-
((TESTS_RUN++))
|
|
33
|
-
|
|
34
|
-
if [[ "$expected" == "$actual" ]]; then
|
|
35
|
-
((TESTS_PASSED++))
|
|
36
|
-
echo -e "${GREEN}✓${NC} $message"
|
|
37
|
-
return 0
|
|
38
|
-
else
|
|
39
|
-
((TESTS_FAILED++))
|
|
40
|
-
echo -e "${RED}✗${NC} $message"
|
|
41
|
-
echo -e " Expected: ${YELLOW}$expected${NC}"
|
|
42
|
-
echo -e " Actual: ${YELLOW}$actual${NC}"
|
|
43
|
-
FAILED_TESTS+=("$message")
|
|
44
|
-
return 1
|
|
45
|
-
fi
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
assert_true() {
|
|
49
|
-
local condition="$1"
|
|
50
|
-
local message="${2:-}"
|
|
51
|
-
|
|
52
|
-
((TESTS_RUN++))
|
|
53
|
-
|
|
54
|
-
if eval "$condition"; then
|
|
55
|
-
((TESTS_PASSED++))
|
|
56
|
-
echo -e "${GREEN}✓${NC} $message"
|
|
57
|
-
return 0
|
|
58
|
-
else
|
|
59
|
-
((TESTS_FAILED++))
|
|
60
|
-
echo -e "${RED}✗${NC} $message"
|
|
61
|
-
echo -e " Condition failed: ${YELLOW}$condition${NC}"
|
|
62
|
-
FAILED_TESTS+=("$message")
|
|
63
|
-
return 1
|
|
64
|
-
fi
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
assert_false() {
|
|
68
|
-
local condition="$1"
|
|
69
|
-
local message="${2:-}"
|
|
70
|
-
|
|
71
|
-
((TESTS_RUN++))
|
|
72
|
-
|
|
73
|
-
if ! eval "$condition"; then
|
|
74
|
-
((TESTS_PASSED++))
|
|
75
|
-
echo -e "${GREEN}✓${NC} $message"
|
|
76
|
-
return 0
|
|
77
|
-
else
|
|
78
|
-
((TESTS_FAILED++))
|
|
79
|
-
echo -e "${RED}✗${NC} $message"
|
|
80
|
-
echo -e " Condition should have failed: ${YELLOW}$condition${NC}"
|
|
81
|
-
FAILED_TESTS+=("$message")
|
|
82
|
-
return 1
|
|
83
|
-
fi
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
# Test suite header
|
|
87
|
-
print_suite_header() {
|
|
88
|
-
echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
89
|
-
echo -e "${BLUE}Testing: $1${NC}"
|
|
90
|
-
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n"
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
# Run test files
|
|
94
|
-
run_test_file() {
|
|
95
|
-
local test_file="$1"
|
|
96
|
-
|
|
97
|
-
if [[ -f "$test_file" && -x "$test_file" ]]; then
|
|
98
|
-
bash "$test_file"
|
|
99
|
-
else
|
|
100
|
-
echo -e "${YELLOW}Skipping $test_file (not found or not executable)${NC}"
|
|
101
|
-
fi
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
# Main test execution
|
|
105
|
-
main() {
|
|
106
|
-
echo -e "${BLUE}╔═══════════════════════════════════════╗${NC}"
|
|
107
|
-
echo -e "${BLUE}║ Library Unit Test Suite ║${NC}"
|
|
108
|
-
echo -e "${BLUE}╚═══════════════════════════════════════╝${NC}"
|
|
109
|
-
|
|
110
|
-
# Export test functions for use in test files
|
|
111
|
-
export -f assert_equals assert_true assert_false print_suite_header
|
|
112
|
-
export RED GREEN YELLOW BLUE NC
|
|
113
|
-
export LIB_DIR
|
|
114
|
-
|
|
115
|
-
# Run individual test files (sourced, not executed)
|
|
116
|
-
source "$SCRIPT_DIR/test_version.sh"
|
|
117
|
-
source "$SCRIPT_DIR/test_validation.sh"
|
|
118
|
-
source "$SCRIPT_DIR/test_git.sh"
|
|
119
|
-
source "$SCRIPT_DIR/test_changelog.sh"
|
|
120
|
-
source "$SCRIPT_DIR/test_gem.sh" # Summary
|
|
121
|
-
echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
122
|
-
echo -e "${BLUE}Test Summary${NC}"
|
|
123
|
-
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
124
|
-
echo -e "Total: $TESTS_RUN"
|
|
125
|
-
echo -e "${GREEN}Passed: $TESTS_PASSED${NC}"
|
|
126
|
-
echo -e "${RED}Failed: $TESTS_FAILED${NC}"
|
|
127
|
-
|
|
128
|
-
if [[ $TESTS_FAILED -gt 0 ]]; then
|
|
129
|
-
echo -e "\n${RED}Failed tests:${NC}"
|
|
130
|
-
for test in "${FAILED_TESTS[@]}"; do
|
|
131
|
-
echo -e " ${RED}✗${NC} $test"
|
|
132
|
-
done
|
|
133
|
-
exit 1
|
|
134
|
-
else
|
|
135
|
-
echo -e "\n${GREEN}All tests passed! 🎉${NC}"
|
|
136
|
-
exit 0
|
|
137
|
-
fi
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
main "$@"
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Unit tests for changelog.sh library
|
|
4
|
-
|
|
5
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
-
LIB_DIR="$(dirname "$SCRIPT_DIR")"
|
|
7
|
-
|
|
8
|
-
# Set up test environment
|
|
9
|
-
export DRY_RUN=true
|
|
10
|
-
export INTERACTIVE=false
|
|
11
|
-
export VERBOSE=false
|
|
12
|
-
|
|
13
|
-
# Source the library
|
|
14
|
-
source "$LIB_DIR/changelog.sh"
|
|
15
|
-
|
|
16
|
-
print_suite_header "changelog.sh"
|
|
17
|
-
|
|
18
|
-
# Test: clean_commit_message
|
|
19
|
-
echo "Testing clean_commit_message..."
|
|
20
|
-
|
|
21
|
-
result=$(clean_commit_message "feat: add new feature")
|
|
22
|
-
assert_equals "Add new feature" "$result" "Clean 'feat:' prefix"
|
|
23
|
-
|
|
24
|
-
result=$(clean_commit_message "fix: resolve bug")
|
|
25
|
-
assert_equals "Resolve bug" "$result" "Clean 'fix:' prefix"
|
|
26
|
-
|
|
27
|
-
result=$(clean_commit_message "feat(scope): add scoped feature")
|
|
28
|
-
assert_equals "Add scoped feature" "$result" "Clean 'feat(scope):' prefix"
|
|
29
|
-
|
|
30
|
-
result=$(clean_commit_message "chore: update dependencies")
|
|
31
|
-
assert_equals "Update dependencies" "$result" "Clean 'chore:' prefix"
|
|
32
|
-
|
|
33
|
-
result=$(clean_commit_message "docs: improve readme")
|
|
34
|
-
assert_equals "Improve readme" "$result" "Clean 'docs:' prefix and capitalize"
|
|
35
|
-
|
|
36
|
-
result=$(clean_commit_message "regular commit message")
|
|
37
|
-
assert_equals "Regular commit message" "$result" "Capitalize regular message"
|
|
38
|
-
|
|
39
|
-
# Test: categorize_commit (requires git, so we test the logic patterns)
|
|
40
|
-
echo -e "\nTesting commit categorization patterns..."
|
|
41
|
-
|
|
42
|
-
# Simulate commit subjects for categorization
|
|
43
|
-
test_categorization() {
|
|
44
|
-
local subject="$1"
|
|
45
|
-
local expected="$2"
|
|
46
|
-
|
|
47
|
-
# Create temporary test function that returns category based on patterns
|
|
48
|
-
local subject_lower=$(echo "$subject" | tr '[:upper:]' '[:lower:]')
|
|
49
|
-
local category="other"
|
|
50
|
-
|
|
51
|
-
case "$subject_lower" in
|
|
52
|
-
feat:*|feature:*|add:*|new:*)
|
|
53
|
-
category="added"
|
|
54
|
-
;;
|
|
55
|
-
fix:*|bugfix:*|bug:*|patch:*)
|
|
56
|
-
category="fixed"
|
|
57
|
-
;;
|
|
58
|
-
*breaking*)
|
|
59
|
-
category="breaking"
|
|
60
|
-
;;
|
|
61
|
-
perf:*|performance:*|refactor:*|style:*|docs:*|doc:*|test:*|chore:*|ci:*|build:*)
|
|
62
|
-
category="changed"
|
|
63
|
-
;;
|
|
64
|
-
revert:*|remove:*|delete:*)
|
|
65
|
-
category="removed"
|
|
66
|
-
;;
|
|
67
|
-
deprecate:*|deprecated:*)
|
|
68
|
-
category="deprecated"
|
|
69
|
-
;;
|
|
70
|
-
security:*|sec:*)
|
|
71
|
-
category="security"
|
|
72
|
-
;;
|
|
73
|
-
esac
|
|
74
|
-
|
|
75
|
-
assert_equals "$expected" "$category" "Categorize: '$subject' → $expected"
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
test_categorization "feat: new feature" "added"
|
|
79
|
-
test_categorization "fix: bug fix" "fixed"
|
|
80
|
-
test_categorization "chore: update" "changed"
|
|
81
|
-
test_categorization "docs: improve" "changed"
|
|
82
|
-
test_categorization "remove: old code" "removed"
|
|
83
|
-
test_categorization "security: patch vulnerability" "security"
|
|
84
|
-
test_categorization "BREAKING: major change" "breaking"
|
|
85
|
-
test_categorization "random commit" "other"
|
|
86
|
-
|
|
87
|
-
echo -e "\n${GREEN}changelog.sh tests complete${NC}"
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Unit tests for gem.sh library
|
|
4
|
-
|
|
5
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
-
LIB_DIR="$(dirname "$SCRIPT_DIR")"
|
|
7
|
-
|
|
8
|
-
# Set up test environment
|
|
9
|
-
export DRY_RUN=true
|
|
10
|
-
export INTERACTIVE=false
|
|
11
|
-
export VERBOSE=false
|
|
12
|
-
|
|
13
|
-
# Source the library
|
|
14
|
-
source "$LIB_DIR/gem.sh"
|
|
15
|
-
|
|
16
|
-
print_suite_header "gem.sh"
|
|
17
|
-
|
|
18
|
-
# Test: gem_version_exists
|
|
19
|
-
echo "Testing gem_version_exists..."
|
|
20
|
-
|
|
21
|
-
# Test with a version that should exist (v1.0.0 is common)
|
|
22
|
-
if gem_version_exists "1.0.0" 2>/dev/null; then
|
|
23
|
-
echo -e "${YELLOW}ℹ${NC} Version 1.0.0 exists on RubyGems"
|
|
24
|
-
else
|
|
25
|
-
echo -e "${YELLOW}ℹ${NC} Version 1.0.0 does not exist on RubyGems"
|
|
26
|
-
fi
|
|
27
|
-
|
|
28
|
-
# Test with a version that definitely shouldn't exist
|
|
29
|
-
if gem_version_exists "999.999.999" 2>/dev/null; then
|
|
30
|
-
assert_false "true" "Non-existent version not found"
|
|
31
|
-
else
|
|
32
|
-
assert_false "false" "Non-existent version not found"
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
# Test: Gem operations (dry run)
|
|
36
|
-
echo -e "\nTesting gem operations in dry run mode..."
|
|
37
|
-
|
|
38
|
-
# Test build_gem in dry run
|
|
39
|
-
if build_gem "1.0.0" 2>/dev/null; then
|
|
40
|
-
assert_true "true" "Dry run: build_gem"
|
|
41
|
-
else
|
|
42
|
-
assert_true "false" "Dry run: build_gem"
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
# Test publish_gem in dry run
|
|
46
|
-
if publish_gem "1.0.0" 2>/dev/null; then
|
|
47
|
-
assert_true "true" "Dry run: publish_gem"
|
|
48
|
-
else
|
|
49
|
-
# May fail due to missing gem file, that's ok in dry run
|
|
50
|
-
echo -e "${YELLOW}ℹ${NC} Dry run: publish_gem (skipped - no gem file)"
|
|
51
|
-
fi
|
|
52
|
-
|
|
53
|
-
# Test create_github_release in dry run
|
|
54
|
-
if create_github_release "1.0.0" 2>/dev/null; then
|
|
55
|
-
assert_true "true" "Dry run: create_github_release"
|
|
56
|
-
else
|
|
57
|
-
# May fail if gh CLI not available, that's ok
|
|
58
|
-
echo -e "${YELLOW}ℹ${NC} Dry run: create_github_release (skipped - gh CLI may not be available)"
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
# Test run_tests in dry run
|
|
62
|
-
if run_tests 2>/dev/null; then
|
|
63
|
-
assert_true "true" "Dry run: run_tests"
|
|
64
|
-
else
|
|
65
|
-
assert_true "false" "Dry run: run_tests"
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
echo -e "\n${GREEN}gem.sh tests complete${NC}"
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Unit tests for git.sh library
|
|
4
|
-
|
|
5
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
-
LIB_DIR="$(dirname "$SCRIPT_DIR")"
|
|
7
|
-
|
|
8
|
-
# Set up test environment
|
|
9
|
-
export DRY_RUN=true
|
|
10
|
-
export INTERACTIVE=false
|
|
11
|
-
export VERBOSE=false
|
|
12
|
-
|
|
13
|
-
# Source the library
|
|
14
|
-
source "$LIB_DIR/git.sh"
|
|
15
|
-
|
|
16
|
-
print_suite_header "git.sh"
|
|
17
|
-
|
|
18
|
-
# Test: get_current_branch
|
|
19
|
-
echo "Testing get_current_branch..."
|
|
20
|
-
|
|
21
|
-
current_branch=$(get_current_branch)
|
|
22
|
-
if [[ -n "$current_branch" ]]; then
|
|
23
|
-
assert_true "true" "Get current branch: $current_branch"
|
|
24
|
-
else
|
|
25
|
-
assert_true "false" "Get current branch"
|
|
26
|
-
fi
|
|
27
|
-
|
|
28
|
-
# Test: get_remote_url
|
|
29
|
-
echo -e "\nTesting get_remote_url..."
|
|
30
|
-
|
|
31
|
-
remote_url=$(get_remote_url "origin" 2>/dev/null)
|
|
32
|
-
if [[ -n "$remote_url" ]]; then
|
|
33
|
-
assert_true "true" "Get remote URL: $remote_url"
|
|
34
|
-
else
|
|
35
|
-
echo -e "${YELLOW}ℹ${NC} No remote URL found (may not be in git repo)"
|
|
36
|
-
fi
|
|
37
|
-
|
|
38
|
-
# Test: get_repo_info
|
|
39
|
-
echo -e "\nTesting get_repo_info..."
|
|
40
|
-
|
|
41
|
-
if [[ -n "$remote_url" ]]; then
|
|
42
|
-
repo_info=$(get_repo_info "origin" 2>/dev/null)
|
|
43
|
-
if [[ -n "$repo_info" ]]; then
|
|
44
|
-
assert_true "true" "Extract repo info: $repo_info"
|
|
45
|
-
else
|
|
46
|
-
echo -e "${YELLOW}ℹ${NC} Could not extract repo info from URL"
|
|
47
|
-
fi
|
|
48
|
-
fi
|
|
49
|
-
|
|
50
|
-
# Test: tag_exists
|
|
51
|
-
echo -e "\nTesting tag_exists..."
|
|
52
|
-
|
|
53
|
-
# Test with a tag that likely doesn't exist
|
|
54
|
-
if tag_exists "v999.999.999"; then
|
|
55
|
-
assert_false "true" "Non-existent tag not found"
|
|
56
|
-
else
|
|
57
|
-
assert_false "false" "Non-existent tag not found"
|
|
58
|
-
fi
|
|
59
|
-
|
|
60
|
-
# Test: get_last_version_tag
|
|
61
|
-
echo -e "\nTesting get_last_version_tag..."
|
|
62
|
-
|
|
63
|
-
last_tag=$(get_last_version_tag 2>/dev/null)
|
|
64
|
-
if [[ -n "$last_tag" ]]; then
|
|
65
|
-
assert_true "true" "Get last version tag: $last_tag"
|
|
66
|
-
else
|
|
67
|
-
echo -e "${YELLOW}ℹ${NC} No version tags found (using initial commit)"
|
|
68
|
-
fi
|
|
69
|
-
|
|
70
|
-
# Test: count_commits_since
|
|
71
|
-
echo -e "\nTesting count_commits_since..."
|
|
72
|
-
|
|
73
|
-
if [[ -n "$last_tag" ]]; then
|
|
74
|
-
commit_count=$(count_commits_since "$last_tag" 2>/dev/null)
|
|
75
|
-
if [[ "$commit_count" =~ ^[0-9]+$ ]]; then
|
|
76
|
-
assert_true "true" "Count commits since $last_tag: $commit_count"
|
|
77
|
-
else
|
|
78
|
-
assert_true "false" "Count commits returns number"
|
|
79
|
-
fi
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
echo -e "\n${GREEN}git.sh tests complete${NC}"
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Unit tests for validation.sh library
|
|
4
|
-
|
|
5
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
-
LIB_DIR="$(dirname "$SCRIPT_DIR")"
|
|
7
|
-
|
|
8
|
-
# Set up test environment
|
|
9
|
-
export DRY_RUN=true
|
|
10
|
-
export INTERACTIVE=false
|
|
11
|
-
export VERBOSE=false
|
|
12
|
-
|
|
13
|
-
# Source the library
|
|
14
|
-
source "$LIB_DIR/validation.sh"
|
|
15
|
-
|
|
16
|
-
print_suite_header "validation.sh"
|
|
17
|
-
|
|
18
|
-
# Test: validate_git_repo (should pass since we're in a git repo)
|
|
19
|
-
echo "Testing validate_git_repo..."
|
|
20
|
-
|
|
21
|
-
if validate_git_repo 2>/dev/null; then
|
|
22
|
-
assert_true "true" "Detects git repository"
|
|
23
|
-
else
|
|
24
|
-
assert_true "false" "Detects git repository"
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
# Test: validate_required_files
|
|
28
|
-
echo -e "\nTesting validate_required_files..."
|
|
29
|
-
|
|
30
|
-
# This will fail if we're not in the project root, but that's expected for tests
|
|
31
|
-
if validate_required_files 2>/dev/null; then
|
|
32
|
-
assert_true "true" "Required files exist"
|
|
33
|
-
else
|
|
34
|
-
# If files don't exist (running from test dir), that's ok for unit tests
|
|
35
|
-
echo -e "${YELLOW}ℹ${NC} Required files check skipped (not in project root)"
|
|
36
|
-
fi
|
|
37
|
-
|
|
38
|
-
# Test: command_exists (from common.sh)
|
|
39
|
-
echo -e "\nTesting command_exists..."
|
|
40
|
-
|
|
41
|
-
if command_exists "git"; then
|
|
42
|
-
assert_true "true" "Git command exists"
|
|
43
|
-
else
|
|
44
|
-
assert_true "false" "Git command exists"
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
if command_exists "bash"; then
|
|
48
|
-
assert_true "true" "Bash command exists"
|
|
49
|
-
else
|
|
50
|
-
assert_true "false" "Bash command exists"
|
|
51
|
-
fi
|
|
52
|
-
|
|
53
|
-
if command_exists "nonexistent_command_xyz"; then
|
|
54
|
-
assert_false "true" "Nonexistent command not found"
|
|
55
|
-
else
|
|
56
|
-
assert_false "false" "Nonexistent command not found"
|
|
57
|
-
fi
|
|
58
|
-
|
|
59
|
-
# Test: validate_dependencies
|
|
60
|
-
echo -e "\nTesting validate_dependencies..."
|
|
61
|
-
|
|
62
|
-
# Test that common dependencies are found
|
|
63
|
-
common_commands=("git" "ruby" "bundle" "jq")
|
|
64
|
-
for cmd in "${common_commands[@]}"; do
|
|
65
|
-
if command_exists "$cmd"; then
|
|
66
|
-
assert_true "true" "Required command exists: $cmd"
|
|
67
|
-
else
|
|
68
|
-
echo -e "${YELLOW}ℹ${NC} Optional command not found: $cmd (skipping)"
|
|
69
|
-
fi
|
|
70
|
-
done
|
|
71
|
-
|
|
72
|
-
echo -e "\n${GREEN}validation.sh tests complete${NC}"
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Unit tests for version.sh library
|
|
4
|
-
|
|
5
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
-
LIB_DIR="$(dirname "$SCRIPT_DIR")"
|
|
7
|
-
|
|
8
|
-
# Set up test environment
|
|
9
|
-
export DRY_RUN=true
|
|
10
|
-
export INTERACTIVE=false
|
|
11
|
-
export VERBOSE=false
|
|
12
|
-
|
|
13
|
-
# Source the library
|
|
14
|
-
source "$LIB_DIR/version.sh"
|
|
15
|
-
|
|
16
|
-
print_suite_header "version.sh"
|
|
17
|
-
|
|
18
|
-
# Test: validate_version_format
|
|
19
|
-
echo "Testing validate_version_format..."
|
|
20
|
-
|
|
21
|
-
valid_versions=("0.0.1" "1.0.0" "10.20.30" "999.999.999")
|
|
22
|
-
for version in "${valid_versions[@]}"; do
|
|
23
|
-
if validate_version_format "$version" 2>/dev/null; then
|
|
24
|
-
assert_true "true" "Valid version format accepted: $version"
|
|
25
|
-
else
|
|
26
|
-
assert_true "false" "Valid version format accepted: $version"
|
|
27
|
-
fi
|
|
28
|
-
done
|
|
29
|
-
|
|
30
|
-
invalid_versions=("1.0" "1.0.0.0" "v1.0.0" "1.0.0-beta" "abc.def.ghi")
|
|
31
|
-
for version in "${invalid_versions[@]}"; do
|
|
32
|
-
if validate_version_format "$version" 2>/dev/null; then
|
|
33
|
-
assert_false "true" "Invalid version format rejected: $version"
|
|
34
|
-
else
|
|
35
|
-
assert_false "false" "Invalid version format rejected: $version"
|
|
36
|
-
fi
|
|
37
|
-
done
|
|
38
|
-
|
|
39
|
-
# Test: calculate_new_version
|
|
40
|
-
echo -e "\nTesting calculate_new_version..."
|
|
41
|
-
|
|
42
|
-
result=$(calculate_new_version "1.2.3" "patch")
|
|
43
|
-
assert_equals "1.2.4" "$result" "Patch bump: 1.2.3 → 1.2.4"
|
|
44
|
-
|
|
45
|
-
result=$(calculate_new_version "1.2.3" "minor")
|
|
46
|
-
assert_equals "1.3.0" "$result" "Minor bump: 1.2.3 → 1.3.0"
|
|
47
|
-
|
|
48
|
-
result=$(calculate_new_version "1.2.3" "major")
|
|
49
|
-
assert_equals "2.0.0" "$result" "Major bump: 1.2.3 → 2.0.0"
|
|
50
|
-
|
|
51
|
-
result=$(calculate_new_version "0.0.9" "patch")
|
|
52
|
-
assert_equals "0.0.10" "$result" "Patch bump with digit rollover: 0.0.9 → 0.0.10"
|
|
53
|
-
|
|
54
|
-
result=$(calculate_new_version "0.9.9" "minor")
|
|
55
|
-
assert_equals "0.10.0" "$result" "Minor bump resets patch: 0.9.9 → 0.10.0"
|
|
56
|
-
|
|
57
|
-
result=$(calculate_new_version "9.9.9" "major")
|
|
58
|
-
assert_equals "10.0.0" "$result" "Major bump resets minor and patch: 9.9.9 → 10.0.0"
|
|
59
|
-
|
|
60
|
-
# Test: version_less_than
|
|
61
|
-
echo -e "\nTesting version_less_than..."
|
|
62
|
-
|
|
63
|
-
if version_less_than "1.0.0" "2.0.0"; then
|
|
64
|
-
assert_true "true" "1.0.0 < 2.0.0"
|
|
65
|
-
else
|
|
66
|
-
assert_true "false" "1.0.0 < 2.0.0"
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
if version_less_than "1.2.3" "1.2.4"; then
|
|
70
|
-
assert_true "true" "1.2.3 < 1.2.4"
|
|
71
|
-
else
|
|
72
|
-
assert_true "false" "1.2.3 < 1.2.4"
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
if version_less_than "2.0.0" "1.0.0"; then
|
|
76
|
-
assert_false "true" "2.0.0 not < 1.0.0"
|
|
77
|
-
else
|
|
78
|
-
assert_false "false" "2.0.0 not < 1.0.0"
|
|
79
|
-
fi
|
|
80
|
-
|
|
81
|
-
if version_less_than "1.2.3" "1.2.3"; then
|
|
82
|
-
assert_false "true" "1.2.3 not < 1.2.3 (equal)"
|
|
83
|
-
else
|
|
84
|
-
assert_false "false" "1.2.3 not < 1.2.3 (equal)"
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# Test: get_version_from_tag
|
|
88
|
-
echo -e "\nTesting get_version_from_tag..."
|
|
89
|
-
|
|
90
|
-
result=$(get_version_from_tag "v1.2.3")
|
|
91
|
-
assert_equals "1.2.3" "$result" "Remove 'v' prefix: v1.2.3 → 1.2.3"
|
|
92
|
-
|
|
93
|
-
result=$(get_version_from_tag "1.2.3")
|
|
94
|
-
assert_equals "1.2.3" "$result" "No prefix to remove: 1.2.3 → 1.2.3"
|
|
95
|
-
|
|
96
|
-
echo -e "\n${GREEN}version.sh tests complete${NC}"
|