"#"
This commit is contained in:
40
tests/unit/state.bats
Normal file
40
tests/unit/state.bats
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bats
|
||||
# tests/unit/state.bats — State key generation tests
|
||||
|
||||
setup() {
|
||||
export JOSH_SYNC_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)"
|
||||
source "$JOSH_SYNC_ROOT/lib/core.sh"
|
||||
source "$JOSH_SYNC_ROOT/lib/state.sh"
|
||||
|
||||
export JOSH_SYNC_TARGET_NAME="billing"
|
||||
}
|
||||
|
||||
@test "state_key generates target/branch format" {
|
||||
local key
|
||||
key=$(state_key "main")
|
||||
[ "$key" = "billing/main" ]
|
||||
}
|
||||
|
||||
@test "state_key converts slashes to hyphens in branch name" {
|
||||
local key
|
||||
key=$(state_key "feature/my-branch")
|
||||
[ "$key" = "billing/feature-my-branch" ]
|
||||
}
|
||||
|
||||
@test "state_key works with different target names" {
|
||||
export JOSH_SYNC_TARGET_NAME="auth-service"
|
||||
local key
|
||||
key=$(state_key "develop")
|
||||
[ "$key" = "auth-service/develop" ]
|
||||
}
|
||||
|
||||
@test "STATE_BRANCH defaults to josh-sync-state" {
|
||||
[ "$STATE_BRANCH" = "josh-sync-state" ]
|
||||
}
|
||||
|
||||
@test "STATE_BRANCH can be overridden via env" {
|
||||
export JOSH_SYNC_STATE_BRANCH="custom-state"
|
||||
# Re-source to pick up the new value
|
||||
source "$JOSH_SYNC_ROOT/lib/state.sh"
|
||||
[ "$STATE_BRANCH" = "custom-state" ]
|
||||
}
|
||||
Reference in New Issue
Block a user