forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-app-config.sh
More file actions
executable file
·74 lines (63 loc) · 3.35 KB
/
Copy pathtest-app-config.sh
File metadata and controls
executable file
·74 lines (63 loc) · 3.35 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MACOS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
source "$MACOS_DIR/scripts/app-config.sh"
fail() {
echo "FAIL: $*" >&2
exit 1
}
assert_eq() {
local expected="$1" actual="$2" label="$3"
if [ "$expected" != "$actual" ]; then
fail "$label: expected '$expected', got '$actual'"
fi
}
assert_config() {
local app_name="$1" expected_is_named="$2" expected_bundle="$3" expected_scheme="$4"
derive_omi_app_config "$app_name"
assert_eq "$app_name" "$APP_NAME" "APP_NAME for $app_name"
assert_eq "$expected_is_named" "$IS_NAMED_BUNDLE" "IS_NAMED_BUNDLE for $app_name"
assert_eq "$expected_bundle" "$EXPECTED_BUNDLE_ID" "EXPECTED_BUNDLE_ID for $app_name"
assert_eq "$expected_scheme" "$EXPECTED_URL_SCHEME" "EXPECTED_URL_SCHEME for $app_name"
assert_eq "$expected_bundle" "$BUNDLE_ID" "BUNDLE_ID for $app_name"
assert_eq "$expected_scheme" "$URL_SCHEME" "URL_SCHEME for $app_name"
}
assert_config "Omi Dev" "false" "com.omi.desktop-dev" "omi-computer-dev"
assert_config "omi-subagent-test" "true" "com.omi.omi-subagent-test" "omi-omi-subagent-test"
assert_config "Omi Subagent Test!!" "true" "com.omi.omi-subagent-test" "omi-omi-subagent-test"
assert_eq "normal" "$(derive_omi_automation_ui_mode false "")" "Omi Dev automation UI default"
assert_eq "quiet" "$(derive_omi_automation_ui_mode true "")" "named bundle automation UI default"
assert_eq "interactive" "$(derive_omi_automation_ui_mode true interactive)" "explicit interactive automation UI"
assert_eq "normal" "$(derive_omi_automation_ui_mode true normal)" "explicit normal automation UI"
if derive_omi_automation_ui_mode true unexpected >/tmp/omi-app-config-ui.out 2>/tmp/omi-app-config-ui.err; then
fail "invalid automation UI mode unexpectedly succeeded"
fi
if ! grep -q "must be normal, quiet, or interactive" /tmp/omi-app-config-ui.err; then
fail "invalid automation UI mode did not explain accepted values"
fi
if derive_omi_app_config "!!!" >/tmp/omi-app-config-invalid.out 2>/tmp/omi-app-config-invalid.err; then
fail "invalid app name unexpectedly succeeded"
fi
if ! grep -q "OMI_APP_NAME must contain at least one letter or number" /tmp/omi-app-config-invalid.err; then
fail "invalid app name did not explain the slug requirement"
fi
if derive_omi_app_config "feature-without-prefix" >/tmp/omi-app-config-prefix.out 2>/tmp/omi-app-config-prefix.err; then
fail "non-omi named app unexpectedly succeeded"
fi
if ! grep -q "must use the omi- prefix" /tmp/omi-app-config-prefix.err; then
fail "non-omi named app did not explain the required prefix"
fi
if OMI_BUNDLE_ID="com.omi.wrong" derive_omi_app_config "omi-subagent-test" >/tmp/omi-app-config-bundle.out 2>/tmp/omi-app-config-bundle.err; then
fail "mismatched OMI_BUNDLE_ID unexpectedly succeeded"
fi
if ! grep -q "must use bundle ID 'com.omi.omi-subagent-test'" /tmp/omi-app-config-bundle.err; then
fail "mismatched OMI_BUNDLE_ID did not report expected bundle id"
fi
if OMI_URL_SCHEME="omi-wrong" derive_omi_app_config "omi-subagent-test" >/tmp/omi-app-config-scheme.out 2>/tmp/omi-app-config-scheme.err; then
fail "mismatched OMI_URL_SCHEME unexpectedly succeeded"
fi
if ! grep -q "must use URL scheme 'omi-omi-subagent-test'" /tmp/omi-app-config-scheme.err; then
fail "mismatched OMI_URL_SCHEME did not report expected URL scheme"
fi
echo "app-config tests passed"