-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-manage-versions.sh
More file actions
executable file
Β·126 lines (106 loc) Β· 3.87 KB
/
test-manage-versions.sh
File metadata and controls
executable file
Β·126 lines (106 loc) Β· 3.87 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
#
# Tests for manage-versions.sh script
#
echo -e "${BLUE}Testing manage-versions.sh${NC}"
# Test show command
run_test_with_output \
"Show command displays version status" \
"$TEST_DIR/scripts/manage-versions.sh show" \
"π Current Version Status"
# Test check command with consistent versions
run_test_with_output \
"Check command validates consistency" \
"$TEST_DIR/scripts/manage-versions.sh check" \
"π Checking Version Consistency"
# Test default command (should be show)
run_test_with_output \
"Default command shows versions" \
"$TEST_DIR/scripts/manage-versions.sh" \
"π Current Version Status"
# Test invalid command
run_test_with_output \
"Invalid command shows usage" \
"$TEST_DIR/scripts/manage-versions.sh invalid-command" \
"Usage:" \
1
# Test update command without version
run_test_with_output \
"Update command without version shows error" \
"$TEST_DIR/scripts/manage-versions.sh update" \
"Please specify a new version" \
1
# Test update command with invalid version format
run_test_with_output \
"Update command with invalid version format" \
"$TEST_DIR/scripts/manage-versions.sh update invalid.version" \
"Invalid version format" \
1
# Test update command with valid version format
run_test_with_output \
"Update command with valid version format" \
"cd '$TEST_DIR' && ./scripts/manage-versions.sh update 0.9.9" \
"π¦ Updating to version 0.9.9"
# Test sync command
run_test_with_output \
"Sync command updates documentation" \
"$TEST_DIR/scripts/manage-versions.sh sync" \
"π Syncing Documentation"
# Test that version inconsistency is detected
create_version_inconsistency() {
# Create inconsistency by modifying README
sed -i 's/Latest Version:\*\* v[0-9]\+\.[0-9]\+\.[0-9]\+/Latest Version:** v9.9.9/' "$TEST_DIR/README.md"
}
run_test \
"Create version inconsistency for testing" \
"$(declare -f create_version_inconsistency); create_version_inconsistency"
run_test_with_output \
"Check command detects inconsistency" \
"$TEST_DIR/scripts/manage-versions.sh check" \
"Version mismatch" \
1
# Test package.json versioning functionality
run_test_with_output \
"Show command displays package.json version" \
"$TEST_DIR/scripts/manage-versions.sh show" \
"π¦ Package.json version"
# Test package.json consistency checking
create_package_inconsistency() {
# Create inconsistency by modifying package.json version
if [[ -f "$TEST_DIR/package.json" ]]; then
sed -i 's/"version": "[^"]*"/"version": "9.8.7"/' "$TEST_DIR/package.json"
fi
}
run_test \
"Create package.json inconsistency for testing" \
"$(declare -f create_package_inconsistency); create_package_inconsistency"
run_test_with_output \
"Check command detects package.json inconsistency" \
"$TEST_DIR/scripts/manage-versions.sh check" \
"Template.*vs.*Package.json" \
1
# Test package.json is updated during version update
run_test_with_output \
"Update command updates package.json version" \
"cd '$TEST_DIR' && ./scripts/manage-versions.sh update 0.8.8" \
"β
Updated package.json"
# Verify package.json version was actually changed
run_test_with_output \
"Package.json version was actually updated" \
"grep '\"version\":' '$TEST_DIR/package.json'" \
"0.8.8"
# Test script dependencies exist
dependencies=("extract-version.sh" "update-versions.sh")
for dep in "${dependencies[@]}"; do
if [[ -f "$TEST_DIR/scripts/$dep" ]]; then
print_test_result "Dependency $dep exists" "PASS"
else
print_test_result "Dependency $dep exists" "FAIL" "Missing dependency: $dep"
fi
done
# Test script is executable
if [[ -x "$TEST_DIR/scripts/manage-versions.sh" ]]; then
print_test_result "Script is executable" "PASS"
else
print_test_result "Script is executable" "FAIL" "Script is not executable"
fi