Skip to content

Commit c10af91

Browse files
committed
Add integration tests for video verification
Enabling the "send password by Talk" property of shares require that Talk is installed and enabled, so the Drone step that runs them has to first clone the Talk repository. When the integration tests are run on a local development instance, however, it is not guaranteed that Talk is installed. Due to this the "@Talk" tag was added, which ensures that any feature or scenario marked with it will first check if Talk is installed and, if not, skip the scenario (instead of failing). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent 64374d3 commit c10af91

4 files changed

Lines changed: 608 additions & 0 deletions

File tree

.drone.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,37 @@ trigger:
12621262
- pull_request
12631263
- push
12641264

1265+
---
1266+
kind: pipeline
1267+
name: integration-sharing-v1-video-verification
1268+
1269+
steps:
1270+
- name: submodules
1271+
image: docker:git
1272+
commands:
1273+
- git submodule update --init
1274+
- name: install-talk
1275+
image: docker:git
1276+
commands:
1277+
# JavaScript files are not used in integration tests so it is not needed to
1278+
# build them.
1279+
- git clone --branch stable17 --depth 1 https://github.com/nextcloud/spreed apps/spreed
1280+
- name: integration-sharing-v1-video-verification
1281+
image: nextcloudci/integration-php7.1:1
1282+
commands:
1283+
- bash tests/drone-run-integration-tests.sh || exit 0
1284+
- ./occ maintenance:install --admin-pass=admin --data-dir=/dev/shm/nc_int
1285+
- cd build/integration
1286+
- ./run.sh features/sharing-v1-video-verification.feature
1287+
1288+
trigger:
1289+
branch:
1290+
- master
1291+
- stable*
1292+
event:
1293+
- pull_request
1294+
- push
1295+
12651296
---
12661297
kind: pipeline
12671298
name: integration-checksums-v1

build/integration/config/behat.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ default:
2525
- CommandLineContext:
2626
baseUrl: http://localhost:8080
2727
ocPath: ../../
28+
- TalkContext
2829
federation:
2930
paths:
3031
- "%paths.base%/../federation_features"
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2020, Daniel Calviño Sánchez (danxuliu@gmail.com)
4+
*
5+
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
use Behat\Behat\Context\Context;
25+
26+
class TalkContext implements Context {
27+
28+
/**
29+
* @BeforeFeature @Talk
30+
* @BeforeScenario @Talk
31+
*/
32+
public static function skipTestsIfTalkIsNotInstalled() {
33+
if (!TalkContext::isTalkInstalled()) {
34+
throw new Exception('Talk needs to be installed to run features or scenarios tagged with @Talk');
35+
}
36+
}
37+
38+
/**
39+
* @AfterScenario @Talk
40+
*/
41+
public static function disableTalk() {
42+
TalkContext::runOcc(['app:disable', 'spreed']);
43+
}
44+
45+
private static function isTalkInstalled(): bool {
46+
$appList = TalkContext::runOcc(['app:list']);
47+
48+
return strpos($appList, 'spreed') !== false;
49+
}
50+
51+
private static function runOcc(array $args): string {
52+
// Based on "runOcc" from CommandLine trait (which can not be used due
53+
// to not being static and being already used in other sibling
54+
// contexts).
55+
$args = array_map(function ($arg) {
56+
return escapeshellarg($arg);
57+
}, $args);
58+
$args[] = '--no-ansi --no-warnings';
59+
$args = implode(' ', $args);
60+
61+
$descriptor = [
62+
0 => ['pipe', 'r'],
63+
1 => ['pipe', 'w'],
64+
2 => ['pipe', 'w'],
65+
];
66+
$process = proc_open('php console.php ' . $args, $descriptor, $pipes, $ocPath = '../..');
67+
$lastStdOut = stream_get_contents($pipes[1]);
68+
proc_close($process);
69+
70+
return $lastStdOut;
71+
}
72+
}

0 commit comments

Comments
 (0)