summaryrefslogtreecommitdiffstatshomepage
path: root/test/integration/lib/example.sh
blob: 2dd1ad6f93a7bfc18b4ab86d8180380f65501c49 (plain) (blame)
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
# Copyright (c) 2026 Egor Tensin <egor@tensin.name>
# This file is part of the "cgitize" project.
# For details, see https://github.com/egor-tensin/cgitize
# Distributed under the MIT License.

_sed_config() {
    if [ "$#" -ne 1 ]; then
        log "usage: ${FUNCNAME[0]} EXPR"
        return 1
    fi

    sed -i -E -e "$1" -- "$test_config_path"
}

_test_example_setup_config() {
    test_config_path="$test_root_dir/cgitize.toml"
    log "Config path: $test_config_path"

    cp -- "$tests_dir/../../examples/cgitize.toml" "$test_config_path"

    _sed_config 's@^output_dir = .*$@output_dir = "'"$test_output_dir"'"@'
    test_example_clone_ssh
    test_example_private_skip
}

test_example_setup() {
    test_output_dir="$test_root_dir/output"
    log "Output directory: $test_output_dir"

    _test_example_setup_config
}

test_example_clone_ssh() {
    _sed_config 's/^clone_via_ssh = (true|false)$/clone_via_ssh = true/'
}

test_example_clone_https() {
    _sed_config 's/^clone_via_ssh = (true|false)$/clone_via_ssh = false/'
}

test_example_private_include() {
    _sed_config 's/^private = (true|false)$/private = true/'
}

test_example_private_skip() {
    _sed_config 's/^private = (true|false)$/private = false/'
}