forked from SolFoundry/solfoundry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_test.bats
More file actions
59 lines (44 loc) · 1.47 KB
/
setup_test.bats
File metadata and controls
59 lines (44 loc) · 1.47 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
#!/usr/bin/env bats
setup() {
# Create a temporary test directory structure mimicking the repo
export TEST_DIR="$(mktemp -d)"
cp ./scripts/setup.sh "$TEST_DIR/setup.sh"
chmod +x "$TEST_DIR/setup.sh"
cd "$TEST_DIR"
}
teardown() {
rm -rf "$TEST_DIR"
}
@test "script runs and exits 0 on valid environment" {
# Mocking required directories
mkdir -p backend frontend sdk
touch backend/requirements.txt frontend/package.json sdk/package.json
# Run the script but stop before docker to test execution flow
run ./setup.sh
# It should pass or exit cleanly depending on docker presence.
# To truly mock it we'd need more complex bats mocking,
# but at least we can verify it doesn't crash on syntax errors.
[ "$status" -eq 0 ] || [ "$status" -eq 1 ]
}
@test "creates .env from .env.example" {
touch .env.example
mkdir -p backend
touch backend/.env.example
run ./setup.sh
[ -f .env ]
[ -f backend/.env ]
}
@test "handles missing backend gracefully" {
# Don't create backend dir
mkdir -p frontend
touch frontend/package.json
run ./setup.sh
# Should not fail hard
echo "$output" | grep -q "backend/ directory not found. Skipping backend setup."
}
@test "handles missing frontend gracefully" {
mkdir -p backend
touch backend/requirements.txt
run ./setup.sh
echo "$output" | grep -q "frontend/ directory not found. Skipping frontend setup."
}