mirror of
https://github.com/qdm12/gluetun.git
synced 2025-12-11 13:56:50 -06:00
- Retro-compatibility: `OPENVPN_CUSTOM_CONFIG` set implies `VPNSP=custom` - Change: `up` and `down` options are not filtered out - Change: `OPENVPN_INTERFACE` overrides the network interface defined in the configuration file - Change: `PORT` overrides any port found in the configuration file - Feat: config file is read when building the OpenVPN configuration, so it's effectively reloaded on VPN restarts - Feat: extract values from custom file at start to log out valid settings - Maint: `internal/openvpn/extract` package instead of `internal/openvpn/custom` package - Maint: All providers' `BuildConf` method return an error - Maint: rename `CustomConfig` to `ConfFile` in Settings structures
33 lines
629 B
Go
33 lines
629 B
Go
package extract
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_readCustomConfigLines(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
file, err := os.CreateTemp("", "")
|
|
require.NoError(t, err)
|
|
defer removeFile(t, file.Name())
|
|
defer file.Close()
|
|
|
|
_, err = file.WriteString("line one\nline two\nline three\n")
|
|
require.NoError(t, err)
|
|
|
|
err = file.Close()
|
|
require.NoError(t, err)
|
|
|
|
lines, err := readCustomConfigLines(file.Name())
|
|
assert.NoError(t, err)
|
|
|
|
expectedLines := []string{
|
|
"line one", "line two", "line three", "",
|
|
}
|
|
assert.Equal(t, expectedLines, lines)
|
|
}
|