-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctional_test.sh
More file actions
executable file
·91 lines (74 loc) · 1.86 KB
/
functional_test.sh
File metadata and controls
executable file
·91 lines (74 loc) · 1.86 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
#!/bin/bash
set -e
# Setup environment
export TEST_DIR="functional_test_run"
rm -rf "$TEST_DIR"
mkdir "$TEST_DIR"
cd "$TEST_DIR"
# Ensure we have a valid environment/config
# We assume 'buckets setup' was run or logic falls back to global config which works.
# We will use 'buckets init' and rely on global config if present.
echo "=== Init ==="
buckets init test_repo
cd test_repo
echo "=== Create Bucket ==="
buckets create test_bucket
cd test_bucket
echo "=== Commit ==="
echo "v1" > file.txt
buckets commit "commit v1"
echo "=== Modify ==="
echo "v2" > file.txt
buckets commit "commit v2"
echo "=== History ==="
buckets history
# Capture commit IDs
IDS=$(buckets history --json | grep "\"id\":" | cut -d '"' -f 4)
ID_V2=$(echo "$IDS" | sed -n '1p')
ID_V1=$(echo "$IDS" | sed -n '2p')
echo "Commit V1: $ID_V1"
echo "Commit V2: $ID_V2"
if [ -z "$ID_V1" ]; then
echo "FAIL: Could not find Commit V1"
exit 1
fi
echo "=== Revert ==="
# Revert to V1
buckets revert --commit "$ID_V1"
CONTENT=$(cat file.txt)
echo "Content after revert: $CONTENT"
if [ "$CONTENT" == "v1" ]; then
echo "PASS: Revert successful"
else
echo "FAIL: Revert failed. Expected 'v1', got '$CONTENT'"
exit 1
fi
echo "=== Commit Revert ==="
buckets commit "Reverted to V1"
echo "=== Rollback ==="
echo "v3 (uncommitted)" > file.txt
buckets rollback
CONTENT=$(cat file.txt)
if [ "$CONTENT" == "v1" ]; then
echo "PASS: Rollback successful"
else
echo "FAIL: Rollback failed. Expected 'v1', got '$CONTENT'"
exit 1
fi
echo "=== Stash ==="
echo "stash me" > stash.txt
buckets stash
if [ -f "stash.txt" ]; then
echo "FAIL: Stash did not remove file"
exit 1
else
echo "PASS: Stash removed file"
fi
buckets stash pop
if grep -q "stash me" stash.txt; then
echo "PASS: Stash pop successful"
else
echo "FAIL: Stash pop failed"
exit 1
fi
echo "ALL FUNCTIONAL TESTS PASSED"