forked from nextcloud-snap/nextcloud-snap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nextcloud: migration: add nextcloud config
maintenance_window_start
- Loading branch information
1 parent
9be79e5
commit b1c1efe
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/nextcloud/fixes/existing-install/7_add_maintenance_window.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh -e | ||
|
||
# Check if config 'maintenance_window_start' doesn't exist or has no value set | ||
if ! occ -n config:system:get maintenance_window_start; then | ||
# Set default 'maintenance_window_start' to 1 a.m. (UTC) | ||
occ -n config:system:set maintenance_window_start --value=1 --type=integer | ||
fi |
50 changes: 50 additions & 0 deletions
50
tests/unit/migrations/add_maintenance_window_start_spec.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Describe 'add-maintenance-window-start migration' | ||
BeforeEach 'setup' | ||
AfterEach 'teardown' | ||
setup() | ||
{ | ||
SPEC_TMPDIR="$(mktemp --directory --tmpdir nextcloud-snap-tests.XXXXXXXXXX)" | ||
MIGRATION="src/migrations/migrations/28.0.0snap1/1_add-maintenance-window-start.sh" | ||
|
||
# Create nextcloud config for the migration to tweak | ||
mkdir -p "$SPEC_TMPDIR/nextcloud/config" | ||
CONFIG_FILE="$SPEC_TMPDIR/nextcloud/config/config.php" | ||
touch "$CONFIG_FILE" | ||
|
||
# Make the migration look in the right place | ||
export SNAP_DATA="$SPEC_TMPDIR" | ||
} | ||
|
||
teardown() | ||
{ | ||
rm -rf "$SPEC_TMPDIR" | ||
} | ||
|
||
It 'handles empty config file' | ||
When call "$MIGRATION" | ||
The status should be failure | ||
End | ||
|
||
It 'handles basic config file' | ||
cat <<- "EOF" > "$CONFIG_FILE" | ||
?php | ||
$CONFIG = array( | ||
); | ||
EOF | ||
|
||
expected_content=$(cat <<- "EOF" | ||
?php | ||
$CONFIG = array( | ||
'maintenance_window_start' => 1, | ||
); | ||
EOF | ||
) | ||
|
||
When call "$MIGRATION" | ||
The status should be success | ||
The output should include "The config ''maintenance_window_start' => 1,' has been added" | ||
The contents of file "$CONFIG_FILE" should equal "$expected_content" | ||
End | ||
End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters