pushwork 2.0.0-a.sub.1 → 2.0.0-preview
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.
- package/dist/branches.d.ts +19 -0
- package/dist/branches.d.ts.map +1 -0
- package/dist/branches.js +111 -0
- package/dist/branches.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +238 -272
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +84 -0
- package/dist/config.js.map +1 -0
- package/dist/fs-tree.d.ts +6 -0
- package/dist/fs-tree.d.ts.map +1 -0
- package/dist/fs-tree.js +99 -0
- package/dist/fs-tree.js.map +1 -0
- package/dist/ignore.d.ts +6 -0
- package/dist/ignore.d.ts.map +1 -0
- package/dist/ignore.js +74 -0
- package/dist/ignore.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/log.d.ts +3 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +14 -0
- package/dist/log.js.map +1 -0
- package/dist/pushwork.d.ts +115 -0
- package/dist/pushwork.d.ts.map +1 -0
- package/dist/pushwork.js +918 -0
- package/dist/pushwork.js.map +1 -0
- package/dist/repo.d.ts +14 -0
- package/dist/repo.d.ts.map +1 -0
- package/dist/repo.js +60 -0
- package/dist/repo.js.map +1 -0
- package/dist/shapes/custom.d.ts +3 -0
- package/dist/shapes/custom.d.ts.map +1 -0
- package/dist/shapes/custom.js +57 -0
- package/dist/shapes/custom.js.map +1 -0
- package/dist/shapes/file.d.ts +20 -0
- package/dist/shapes/file.d.ts.map +1 -0
- package/dist/shapes/file.js +140 -0
- package/dist/shapes/file.js.map +1 -0
- package/dist/shapes/index.d.ts +10 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +35 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/patchwork-folder.d.ts +3 -0
- package/dist/shapes/patchwork-folder.d.ts.map +1 -0
- package/dist/shapes/patchwork-folder.js +160 -0
- package/dist/shapes/patchwork-folder.js.map +1 -0
- package/dist/shapes/types.d.ts +37 -0
- package/dist/shapes/types.d.ts.map +1 -0
- package/dist/shapes/types.js +52 -0
- package/dist/shapes/types.js.map +1 -0
- package/dist/shapes/vfs.d.ts +3 -0
- package/dist/shapes/vfs.d.ts.map +1 -0
- package/dist/shapes/vfs.js +88 -0
- package/dist/shapes/vfs.js.map +1 -0
- package/dist/stash.d.ts +23 -0
- package/dist/stash.d.ts.map +1 -0
- package/dist/stash.js +118 -0
- package/dist/stash.js.map +1 -0
- package/flake.lock +128 -0
- package/flake.nix +66 -0
- package/package.json +15 -48
- package/patches/@automerge__automerge-repo@2.6.0-subduction.15.patch +26 -0
- package/pnpm-workspace.yaml +5 -0
- package/src/branches.ts +93 -0
- package/src/cli.ts +258 -408
- package/src/config.ts +64 -0
- package/src/fs-tree.ts +70 -0
- package/src/ignore.ts +33 -0
- package/src/index.ts +38 -4
- package/src/log.ts +8 -0
- package/src/pushwork.ts +1055 -0
- package/src/repo.ts +76 -0
- package/src/shapes/custom.ts +29 -0
- package/src/shapes/file.ts +115 -0
- package/src/shapes/index.ts +19 -0
- package/src/shapes/patchwork-folder.ts +156 -0
- package/src/shapes/types.ts +79 -0
- package/src/shapes/vfs.ts +93 -0
- package/src/stash.ts +106 -0
- package/test/integration/branches.test.ts +389 -0
- package/test/integration/pushwork.test.ts +547 -0
- package/test/setup.ts +29 -0
- package/test/unit/doc-shape.test.ts +612 -0
- package/tsconfig.json +2 -3
- package/vitest.config.ts +14 -0
- package/ARCHITECTURE-ACCORDING-TO-CLAUDE.md +0 -248
- package/CLAUDE.md +0 -141
- package/README.md +0 -221
- package/babel.config.js +0 -5
- package/dist/cli/commands.d.ts +0 -71
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -794
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -19
- package/dist/cli/index.js.map +0 -1
- package/dist/commands.d.ts +0 -61
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -861
- package/dist/commands.js.map +0 -1
- package/dist/config/index.d.ts +0 -71
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -314
- package/dist/config/index.js.map +0 -1
- package/dist/core/change-detection.d.ts +0 -80
- package/dist/core/change-detection.d.ts.map +0 -1
- package/dist/core/change-detection.js +0 -523
- package/dist/core/change-detection.js.map +0 -1
- package/dist/core/config.d.ts +0 -81
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -258
- package/dist/core/config.js.map +0 -1
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -6
- package/dist/core/index.js.map +0 -1
- package/dist/core/move-detection.d.ts +0 -34
- package/dist/core/move-detection.d.ts.map +0 -1
- package/dist/core/move-detection.js +0 -121
- package/dist/core/move-detection.js.map +0 -1
- package/dist/core/snapshot.d.ts +0 -105
- package/dist/core/snapshot.d.ts.map +0 -1
- package/dist/core/snapshot.js +0 -217
- package/dist/core/snapshot.js.map +0 -1
- package/dist/core/sync-engine.d.ts +0 -157
- package/dist/core/sync-engine.d.ts.map +0 -1
- package/dist/core/sync-engine.js +0 -1379
- package/dist/core/sync-engine.js.map +0 -1
- package/dist/types/config.d.ts +0 -99
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -5
- package/dist/types/config.js.map +0 -1
- package/dist/types/documents.d.ts +0 -88
- package/dist/types/documents.d.ts.map +0 -1
- package/dist/types/documents.js +0 -20
- package/dist/types/documents.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/snapshot.d.ts +0 -64
- package/dist/types/snapshot.d.ts.map +0 -1
- package/dist/types/snapshot.js +0 -2
- package/dist/types/snapshot.js.map +0 -1
- package/dist/utils/content-similarity.d.ts +0 -53
- package/dist/utils/content-similarity.d.ts.map +0 -1
- package/dist/utils/content-similarity.js +0 -155
- package/dist/utils/content-similarity.js.map +0 -1
- package/dist/utils/content.d.ts +0 -10
- package/dist/utils/content.d.ts.map +0 -1
- package/dist/utils/content.js +0 -31
- package/dist/utils/content.js.map +0 -1
- package/dist/utils/directory.d.ts +0 -24
- package/dist/utils/directory.d.ts.map +0 -1
- package/dist/utils/directory.js +0 -52
- package/dist/utils/directory.js.map +0 -1
- package/dist/utils/fs.d.ts +0 -74
- package/dist/utils/fs.d.ts.map +0 -1
- package/dist/utils/fs.js +0 -248
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -5
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/mime-types.d.ts +0 -13
- package/dist/utils/mime-types.d.ts.map +0 -1
- package/dist/utils/mime-types.js +0 -209
- package/dist/utils/mime-types.js.map +0 -1
- package/dist/utils/network-sync.d.ts +0 -36
- package/dist/utils/network-sync.d.ts.map +0 -1
- package/dist/utils/network-sync.js +0 -250
- package/dist/utils/network-sync.js.map +0 -1
- package/dist/utils/node-polyfills.d.ts +0 -9
- package/dist/utils/node-polyfills.d.ts.map +0 -1
- package/dist/utils/node-polyfills.js +0 -9
- package/dist/utils/node-polyfills.js.map +0 -1
- package/dist/utils/output.d.ts +0 -129
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/output.js +0 -368
- package/dist/utils/output.js.map +0 -1
- package/dist/utils/repo-factory.d.ts +0 -13
- package/dist/utils/repo-factory.d.ts.map +0 -1
- package/dist/utils/repo-factory.js +0 -46
- package/dist/utils/repo-factory.js.map +0 -1
- package/dist/utils/string-similarity.d.ts +0 -14
- package/dist/utils/string-similarity.d.ts.map +0 -1
- package/dist/utils/string-similarity.js +0 -39
- package/dist/utils/string-similarity.js.map +0 -1
- package/dist/utils/text-diff.d.ts +0 -37
- package/dist/utils/text-diff.d.ts.map +0 -1
- package/dist/utils/text-diff.js +0 -93
- package/dist/utils/text-diff.js.map +0 -1
- package/dist/utils/trace.d.ts +0 -19
- package/dist/utils/trace.d.ts.map +0 -1
- package/dist/utils/trace.js +0 -63
- package/dist/utils/trace.js.map +0 -1
- package/src/commands.ts +0 -1134
- package/src/core/change-detection.ts +0 -712
- package/src/core/config.ts +0 -313
- package/src/core/index.ts +0 -5
- package/src/core/move-detection.ts +0 -169
- package/src/core/snapshot.ts +0 -275
- package/src/core/sync-engine.ts +0 -1795
- package/src/types/config.ts +0 -111
- package/src/types/documents.ts +0 -91
- package/src/types/index.ts +0 -3
- package/src/types/snapshot.ts +0 -67
- package/src/utils/content.ts +0 -34
- package/src/utils/directory.ts +0 -73
- package/src/utils/fs.ts +0 -297
- package/src/utils/index.ts +0 -4
- package/src/utils/mime-types.ts +0 -244
- package/src/utils/network-sync.ts +0 -319
- package/src/utils/node-polyfills.ts +0 -8
- package/src/utils/output.ts +0 -450
- package/src/utils/repo-factory.ts +0 -73
- package/src/utils/string-similarity.ts +0 -54
- package/src/utils/text-diff.ts +0 -101
- package/src/utils/trace.ts +0 -70
- package/test/integration/README.md +0 -328
- package/test/integration/clone-test.sh +0 -310
- package/test/integration/conflict-resolution-test.sh +0 -309
- package/test/integration/debug-both-nested.sh +0 -74
- package/test/integration/debug-concurrent-nested.sh +0 -87
- package/test/integration/debug-nested.sh +0 -73
- package/test/integration/deletion-behavior-test.sh +0 -487
- package/test/integration/deletion-sync-test-simple.sh +0 -193
- package/test/integration/deletion-sync-test.sh +0 -297
- package/test/integration/exclude-patterns.test.ts +0 -144
- package/test/integration/full-integration-test.sh +0 -363
- package/test/integration/fuzzer.test.ts +0 -818
- package/test/integration/in-memory-sync.test.ts +0 -830
- package/test/integration/init-sync.test.ts +0 -89
- package/test/integration/manual-sync-test.sh +0 -84
- package/test/integration/sync-deletion.test.ts +0 -280
- package/test/integration/sync-flow.test.ts +0 -291
- package/test/jest.setup.ts +0 -34
- package/test/run-tests.sh +0 -225
- package/test/unit/deletion-behavior.test.ts +0 -249
- package/test/unit/enhanced-mime-detection.test.ts +0 -244
- package/test/unit/snapshot.test.ts +0 -404
- package/test/unit/sync-convergence.test.ts +0 -298
- package/test/unit/sync-timing.test.ts +0 -134
- package/test/unit/utils.test.ts +0 -366
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Comprehensive Integration Test for Pushwork
|
|
4
|
-
# Tests all major functionality of the sync tool
|
|
5
|
-
|
|
6
|
-
set -e # Exit on any error
|
|
7
|
-
|
|
8
|
-
# Colors for output
|
|
9
|
-
RED='\033[0;31m'
|
|
10
|
-
GREEN='\033[0;32m'
|
|
11
|
-
YELLOW='\033[1;33m'
|
|
12
|
-
BLUE='\033[0;34m'
|
|
13
|
-
NC='\033[0m' # No Color
|
|
14
|
-
|
|
15
|
-
# Test configuration
|
|
16
|
-
TEST_DIR="/tmp/pushwork-integration-test"
|
|
17
|
-
PUSHWORK_CMD="node $(pwd)/dist/cli.js"
|
|
18
|
-
CUSTOM_SYNC_SERVER="ws://localhost:3030"
|
|
19
|
-
CUSTOM_STORAGE_ID="1d89eba7-f7a4-4e8e-80f2-5f4e2406f507"
|
|
20
|
-
|
|
21
|
-
# Test counters
|
|
22
|
-
TESTS_RUN=0
|
|
23
|
-
TESTS_PASSED=0
|
|
24
|
-
TESTS_FAILED=0
|
|
25
|
-
|
|
26
|
-
# Helper functions
|
|
27
|
-
log_info() {
|
|
28
|
-
echo -e "${BLUE}[INFO]${NC} $1"
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
log_success() {
|
|
32
|
-
echo -e "${GREEN}[PASS]${NC} $1"
|
|
33
|
-
((TESTS_PASSED++))
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
log_error() {
|
|
37
|
-
echo -e "${RED}[FAIL]${NC} $1"
|
|
38
|
-
((TESTS_FAILED++))
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
log_warning() {
|
|
42
|
-
echo -e "${YELLOW}[WARN]${NC} $1"
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
log_test() {
|
|
46
|
-
echo -e "${YELLOW}[TEST]${NC} $1"
|
|
47
|
-
((TESTS_RUN++))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
# Test wrapper function
|
|
51
|
-
run_test() {
|
|
52
|
-
local test_name="$1"
|
|
53
|
-
local test_cmd="$2"
|
|
54
|
-
local expected_exit_code="${3:-0}"
|
|
55
|
-
|
|
56
|
-
log_test "$test_name"
|
|
57
|
-
|
|
58
|
-
if [ "$expected_exit_code" = "0" ]; then
|
|
59
|
-
if eval "$test_cmd" > /dev/null 2>&1; then
|
|
60
|
-
log_success "$test_name"
|
|
61
|
-
return 0
|
|
62
|
-
else
|
|
63
|
-
log_error "$test_name (command failed)"
|
|
64
|
-
return 1
|
|
65
|
-
fi
|
|
66
|
-
else
|
|
67
|
-
if eval "$test_cmd" > /dev/null 2>&1; then
|
|
68
|
-
log_error "$test_name (expected failure but succeeded)"
|
|
69
|
-
return 1
|
|
70
|
-
else
|
|
71
|
-
log_success "$test_name (correctly failed)"
|
|
72
|
-
return 0
|
|
73
|
-
fi
|
|
74
|
-
fi
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
# Cleanup function
|
|
78
|
-
cleanup() {
|
|
79
|
-
log_info "Cleaning up test directory..."
|
|
80
|
-
rm -rf "$TEST_DIR"
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
# Setup function
|
|
84
|
-
setup() {
|
|
85
|
-
log_info "Setting up integration test environment..."
|
|
86
|
-
|
|
87
|
-
# Build the project first
|
|
88
|
-
log_info "Building pushwork..."
|
|
89
|
-
npm run build
|
|
90
|
-
|
|
91
|
-
# Clean up any existing test directory
|
|
92
|
-
rm -rf "$TEST_DIR"
|
|
93
|
-
mkdir -p "$TEST_DIR"
|
|
94
|
-
cd "$TEST_DIR"
|
|
95
|
-
|
|
96
|
-
log_info "Test directory: $TEST_DIR"
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
# Test functions
|
|
100
|
-
|
|
101
|
-
test_help_commands() {
|
|
102
|
-
log_info "=== Testing Help Commands ==="
|
|
103
|
-
|
|
104
|
-
run_test "pushwork --help" "$PUSHWORK_CMD --help"
|
|
105
|
-
run_test "pushwork init --help" "$PUSHWORK_CMD init --help"
|
|
106
|
-
run_test "pushwork clone --help" "$PUSHWORK_CMD clone --help"
|
|
107
|
-
run_test "pushwork sync --help" "$PUSHWORK_CMD sync --help"
|
|
108
|
-
run_test "pushwork status --help" "$PUSHWORK_CMD status --help"
|
|
109
|
-
run_test "pushwork diff --help" "$PUSHWORK_CMD diff --help"
|
|
110
|
-
run_test "pushwork commit --help" "$PUSHWORK_CMD commit --help"
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
test_init_functionality() {
|
|
114
|
-
log_info "=== Testing Init Functionality ==="
|
|
115
|
-
|
|
116
|
-
# Test init with default settings
|
|
117
|
-
mkdir -p test-init-default
|
|
118
|
-
cd test-init-default
|
|
119
|
-
echo "Hello World" > test.txt
|
|
120
|
-
|
|
121
|
-
run_test "init with default settings" "$PUSHWORK_CMD init ."
|
|
122
|
-
run_test "check .pushwork directory exists" "[ -d .pushwork ]"
|
|
123
|
-
run_test "check config file exists" "[ -f .pushwork/config.json ]"
|
|
124
|
-
run_test "check snapshot file exists" "[ -f .pushwork/snapshot.json ]"
|
|
125
|
-
|
|
126
|
-
cd ..
|
|
127
|
-
|
|
128
|
-
# Test init with custom sync server
|
|
129
|
-
mkdir -p test-init-custom
|
|
130
|
-
cd test-init-custom
|
|
131
|
-
echo "Custom Server Test" > custom.txt
|
|
132
|
-
|
|
133
|
-
run_test "init with custom sync server" "$PUSHWORK_CMD init . --sync-server $CUSTOM_SYNC_SERVER --sync-server-storage-id $CUSTOM_STORAGE_ID"
|
|
134
|
-
|
|
135
|
-
# Verify custom settings in config
|
|
136
|
-
if [ -f .pushwork/config.json ]; then
|
|
137
|
-
if grep -q "$CUSTOM_SYNC_SERVER" .pushwork/config.json; then
|
|
138
|
-
log_success "custom sync server saved in config"
|
|
139
|
-
((TESTS_PASSED++))
|
|
140
|
-
else
|
|
141
|
-
log_error "custom sync server not found in config"
|
|
142
|
-
((TESTS_FAILED++))
|
|
143
|
-
fi
|
|
144
|
-
((TESTS_RUN++))
|
|
145
|
-
|
|
146
|
-
if grep -q "$CUSTOM_STORAGE_ID" .pushwork/config.json; then
|
|
147
|
-
log_success "custom storage ID saved in config"
|
|
148
|
-
((TESTS_PASSED++))
|
|
149
|
-
else
|
|
150
|
-
log_error "custom storage ID not found in config"
|
|
151
|
-
((TESTS_FAILED++))
|
|
152
|
-
fi
|
|
153
|
-
((TESTS_RUN++))
|
|
154
|
-
fi
|
|
155
|
-
|
|
156
|
-
cd ..
|
|
157
|
-
|
|
158
|
-
# Test error cases
|
|
159
|
-
run_test "init already initialized directory" "$PUSHWORK_CMD init test-init-default" 1
|
|
160
|
-
run_test "init with only sync-server (should fail)" "$PUSHWORK_CMD init test-fail --sync-server $CUSTOM_SYNC_SERVER" 1
|
|
161
|
-
run_test "init with only storage-id (should fail)" "$PUSHWORK_CMD init test-fail --sync-server-storage-id $CUSTOM_STORAGE_ID" 1
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
test_status_functionality() {
|
|
165
|
-
log_info "=== Testing Status Functionality ==="
|
|
166
|
-
|
|
167
|
-
cd test-init-default
|
|
168
|
-
run_test "status in initialized directory" "$PUSHWORK_CMD status"
|
|
169
|
-
cd ..
|
|
170
|
-
|
|
171
|
-
run_test "status in non-initialized directory" "$PUSHWORK_CMD status" 1
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
test_commit_functionality() {
|
|
175
|
-
log_info "=== Testing Commit Functionality ==="
|
|
176
|
-
|
|
177
|
-
cd test-init-default
|
|
178
|
-
|
|
179
|
-
# Add some files
|
|
180
|
-
echo "New content" > new-file.txt
|
|
181
|
-
echo "Modified content" >> test.txt
|
|
182
|
-
|
|
183
|
-
run_test "commit with changes" "$PUSHWORK_CMD commit ."
|
|
184
|
-
run_test "commit dry-run" "$PUSHWORK_CMD commit . --dry-run"
|
|
185
|
-
|
|
186
|
-
cd ..
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
test_sync_functionality() {
|
|
190
|
-
log_info "=== Testing Sync Functionality ==="
|
|
191
|
-
|
|
192
|
-
cd test-init-default
|
|
193
|
-
|
|
194
|
-
run_test "sync in initialized directory" "$PUSHWORK_CMD sync"
|
|
195
|
-
run_test "sync dry-run" "$PUSHWORK_CMD sync --dry-run"
|
|
196
|
-
run_test "sync local-only" "$PUSHWORK_CMD sync --local-only"
|
|
197
|
-
|
|
198
|
-
cd ..
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
test_diff_functionality() {
|
|
202
|
-
log_info "=== Testing Diff Functionality ==="
|
|
203
|
-
|
|
204
|
-
cd test-init-default
|
|
205
|
-
|
|
206
|
-
# Make some changes
|
|
207
|
-
echo "Diff test content" > diff-test.txt
|
|
208
|
-
|
|
209
|
-
run_test "diff command" "$PUSHWORK_CMD diff"
|
|
210
|
-
run_test "diff name-only" "$PUSHWORK_CMD diff --name-only"
|
|
211
|
-
run_test "diff local-only" "$PUSHWORK_CMD diff --local-only"
|
|
212
|
-
|
|
213
|
-
cd ..
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
test_clone_functionality() {
|
|
217
|
-
log_info "=== Testing Clone Functionality ==="
|
|
218
|
-
|
|
219
|
-
# First, we need a valid URL to clone from the initialized directory
|
|
220
|
-
cd test-init-default
|
|
221
|
-
|
|
222
|
-
if [ -f .pushwork/snapshot.json ]; then
|
|
223
|
-
ROOT_URL=$($PUSHWORK_CMD url .)
|
|
224
|
-
|
|
225
|
-
if [ -n "$ROOT_URL" ]; then
|
|
226
|
-
cd ..
|
|
227
|
-
|
|
228
|
-
# Test clone with default settings
|
|
229
|
-
run_test "clone with default settings" "$PUSHWORK_CMD clone $ROOT_URL test-clone-default"
|
|
230
|
-
|
|
231
|
-
if [ -d test-clone-default ]; then
|
|
232
|
-
run_test "cloned directory has .pushwork" "[ -d test-clone-default/.pushwork ]"
|
|
233
|
-
run_test "cloned directory has files" "[ -f test-clone-default/test.txt ]"
|
|
234
|
-
fi
|
|
235
|
-
|
|
236
|
-
# Test clone with custom sync server
|
|
237
|
-
run_test "clone with custom sync server" "$PUSHWORK_CMD clone $ROOT_URL test-clone-custom --sync-server $CUSTOM_SYNC_SERVER --sync-server-storage-id $CUSTOM_STORAGE_ID"
|
|
238
|
-
|
|
239
|
-
# Test clone error cases
|
|
240
|
-
mkdir -p existing-dir
|
|
241
|
-
echo "existing" > existing-dir/file.txt
|
|
242
|
-
run_test "clone to non-empty directory (should fail)" "$PUSHWORK_CMD clone $ROOT_URL existing-dir" 1
|
|
243
|
-
run_test "clone with force to non-empty directory" "$PUSHWORK_CMD clone $ROOT_URL existing-dir --force"
|
|
244
|
-
|
|
245
|
-
run_test "clone with only sync-server (should fail)" "$PUSHWORK_CMD clone $ROOT_URL test-fail --sync-server $CUSTOM_SYNC_SERVER" 1
|
|
246
|
-
run_test "clone with only storage-id (should fail)" "$PUSHWORK_CMD clone $ROOT_URL test-fail --sync-server-storage-id $CUSTOM_STORAGE_ID" 1
|
|
247
|
-
else
|
|
248
|
-
log_warning "No valid root URL found, skipping clone tests"
|
|
249
|
-
fi
|
|
250
|
-
else
|
|
251
|
-
log_warning "Snapshot missing - repository not properly initialized, skipping clone tests"
|
|
252
|
-
fi
|
|
253
|
-
|
|
254
|
-
cd ..
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
test_bidirectional_sync() {
|
|
258
|
-
log_info "=== Testing Bidirectional Sync ==="
|
|
259
|
-
|
|
260
|
-
# This test requires both directories to be properly initialized
|
|
261
|
-
if [ -d test-init-default ] && [ -d test-clone-default ]; then
|
|
262
|
-
# Add content in original
|
|
263
|
-
cd test-init-default
|
|
264
|
-
echo "From original" > sync-test.txt
|
|
265
|
-
$PUSHWORK_CMD commit . > /dev/null 2>&1 || true
|
|
266
|
-
cd ..
|
|
267
|
-
|
|
268
|
-
# Add different content in clone
|
|
269
|
-
cd test-clone-default
|
|
270
|
-
echo "From clone" > sync-test-clone.txt
|
|
271
|
-
$PUSHWORK_CMD commit . > /dev/null 2>&1 || true
|
|
272
|
-
cd ..
|
|
273
|
-
|
|
274
|
-
# Try to sync both
|
|
275
|
-
cd test-init-default
|
|
276
|
-
run_test "sync from original" "$PUSHWORK_CMD sync --local-only"
|
|
277
|
-
cd ..
|
|
278
|
-
|
|
279
|
-
cd test-clone-default
|
|
280
|
-
run_test "sync from clone" "$PUSHWORK_CMD sync --local-only"
|
|
281
|
-
cd ..
|
|
282
|
-
else
|
|
283
|
-
log_warning "Clone directories not available, skipping bidirectional sync test"
|
|
284
|
-
fi
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
test_file_operations() {
|
|
288
|
-
log_info "=== Testing File Operations ==="
|
|
289
|
-
|
|
290
|
-
mkdir -p test-file-ops
|
|
291
|
-
cd test-file-ops
|
|
292
|
-
|
|
293
|
-
# Initialize
|
|
294
|
-
$PUSHWORK_CMD init . > /dev/null 2>&1
|
|
295
|
-
|
|
296
|
-
# Test various file operations
|
|
297
|
-
echo "Text file" > text.txt
|
|
298
|
-
echo -e "\x89PNG\r\n\x1a\n" > binary.png # Fake PNG header
|
|
299
|
-
mkdir -p subdir
|
|
300
|
-
echo "Subdirectory file" > subdir/nested.txt
|
|
301
|
-
|
|
302
|
-
run_test "commit various file types" "$PUSHWORK_CMD commit ."
|
|
303
|
-
run_test "status after file operations" "$PUSHWORK_CMD status"
|
|
304
|
-
|
|
305
|
-
# Modify files
|
|
306
|
-
echo "Modified text" >> text.txt
|
|
307
|
-
rm binary.png
|
|
308
|
-
echo "New file" > new.txt
|
|
309
|
-
|
|
310
|
-
run_test "diff after modifications" "$PUSHWORK_CMD diff --name-only"
|
|
311
|
-
run_test "commit modifications" "$PUSHWORK_CMD commit ."
|
|
312
|
-
|
|
313
|
-
cd ..
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
# Main test execution
|
|
317
|
-
main() {
|
|
318
|
-
echo "======================================"
|
|
319
|
-
echo "Pushwork Integration Test Suite"
|
|
320
|
-
echo "======================================"
|
|
321
|
-
|
|
322
|
-
# Trap cleanup on exit
|
|
323
|
-
trap cleanup EXIT
|
|
324
|
-
|
|
325
|
-
# Setup
|
|
326
|
-
setup
|
|
327
|
-
|
|
328
|
-
# Run all tests
|
|
329
|
-
test_help_commands
|
|
330
|
-
test_init_functionality
|
|
331
|
-
test_status_functionality
|
|
332
|
-
test_commit_functionality
|
|
333
|
-
test_sync_functionality
|
|
334
|
-
test_diff_functionality
|
|
335
|
-
test_clone_functionality
|
|
336
|
-
test_bidirectional_sync
|
|
337
|
-
test_file_operations
|
|
338
|
-
|
|
339
|
-
# Summary
|
|
340
|
-
echo ""
|
|
341
|
-
echo "======================================"
|
|
342
|
-
echo "Test Results Summary"
|
|
343
|
-
echo "======================================"
|
|
344
|
-
echo "Tests Run: $TESTS_RUN"
|
|
345
|
-
echo "Tests Passed: $TESTS_PASSED"
|
|
346
|
-
echo "Tests Failed: $TESTS_FAILED"
|
|
347
|
-
|
|
348
|
-
if [ $TESTS_FAILED -eq 0 ]; then
|
|
349
|
-
log_success "All tests passed!"
|
|
350
|
-
exit 0
|
|
351
|
-
else
|
|
352
|
-
log_error "Some tests failed!"
|
|
353
|
-
exit 1
|
|
354
|
-
fi
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
# Check if jq is available (optional dependency)
|
|
358
|
-
if ! command -v jq &> /dev/null; then
|
|
359
|
-
log_warning "jq is not installed - some tests may be skipped"
|
|
360
|
-
fi
|
|
361
|
-
|
|
362
|
-
# Run the tests
|
|
363
|
-
main "$@"
|