Skip to content

Commit 79d0df0

Browse files
committed
chore: add user.ini tests
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent bcad745 commit 79d0df0

4 files changed

Lines changed: 113 additions & 0 deletions

File tree

.github/workflows/test-various.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: MIT
3+
name: Test various integration tests
4+
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- main
10+
- master
11+
- stable*
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test-various:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
php-versions: ["8.2"]
22+
23+
24+
name: test-various
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
29+
30+
- name: Set up php ${{ matrix.php-versions }}
31+
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2
32+
with:
33+
php-version: ${{ matrix.php-versions }}
34+
extensions: apcu,ctype,curl,dom,fileinfo,ftp,gd,intl,json,ldap,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip
35+
coverage: none
36+
ini-file: development
37+
38+
- name: Install dependencies
39+
run: composer i
40+
41+
- name: test-user.ini
42+
run: make test-user.ini
43+
44+
summary:
45+
runs-on: ubuntu-latest
46+
needs: test-various
47+
48+
if: always()
49+
50+
name: test-various-summary
51+
52+
steps:
53+
- name: Summary status
54+
run: if ${{ needs.test-various.result != 'success' }}; then exit 1; fi

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ test-stable26: updater.phar test/vendor
3939
test-master: updater.phar test/vendor
4040
cd tests && ../vendor/bin/behat features/master.feature
4141

42+
test-user.ini: updater.phar test/vendor
43+
cd tests && ../vendor/bin/behat features/user.ini.feature
44+
4245
check-same-code-base:
4346
cd tests && php checkSameCodeBase.php
4447

tests/features/bootstrap/FeatureContext.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,47 @@ public function theCurrentChannelIs($channel) {
402402
exec('./occ config:system:set --value ' . $channel . ' updater.release.channel');
403403
}
404404

405+
/**
406+
* @Given the config key :key is set to :value of type :type
407+
* @param string $key
408+
* @param mixed $value
409+
* @param string $type ('string', 'boolean', 'integer', 'double')
410+
*/
411+
public function theConfigKeyIsSetTo(string $key, $value, string $type = 'string') {
412+
if ($this->skipIt) {
413+
return;
414+
}
415+
416+
if (!in_array($type, ['string', 'boolean', 'integer', 'double'])) {
417+
throw new Exception('Invalid type given: ' . $type);
418+
}
419+
420+
chdir($this->serverDir . 'nextcloud');
421+
shell_exec('chmod +x occ');
422+
exec("./occ config:system:set $key --value '$value' --type '$type'");
423+
}
424+
425+
/**
426+
* @Then the user ini file contains :content
427+
* @param string $content
428+
*/
429+
public function theUserIniFileContains(string $content) {
430+
if ($this->skipIt) {
431+
return;
432+
}
433+
434+
$userIniFile = $this->serverDir . 'nextcloud/.user.ini';
435+
if (!file_exists($userIniFile)) {
436+
throw new Exception('User ini file does not exist: ' . $userIniFile);
437+
}
438+
439+
$contents = file_get_contents($userIniFile);
440+
if (!str_contains($contents, $content)) {
441+
var_dump($contents);
442+
throw new Exception('Content not found in user ini file: ' . $content);
443+
}
444+
}
445+
405446
/**
406447
* @Then /upgrade is (not required|required)/
407448
*/

tests/features/user.ini.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
Feature: CLI updater - user.ini retention test
4+
5+
Scenario: User.ini retention after update
6+
Given the current installed version is 26.0.0rc1
7+
Given the config key "user_ini_additional_lines" is set to "upload_max_filesize = 10G\npost_max_size = 10G" of type "string"
8+
And there is an update to version 26.0.0 available
9+
When the CLI updater is run successfully
10+
And the output should contain "Update successful"
11+
Then the installed version should be 26.0
12+
And maintenance mode should be off
13+
And upgrade is not required
14+
And the user ini file contains "upload_max_filesize = 10G"
15+
And the user ini file contains "post_max_size = 10G"

0 commit comments

Comments
 (0)