forgejo/contrib/environment-to-ini/environment-to-ini_test.go

22 lines
538 B
Go
Raw Normal View History

[BRANDING] parse FORGEJO__* in the container environment Add the FORGEJO__ prefix as equivalent to GITEA__ when interpreted by environment-to-ini. It is used when running the Forgejo container like so: docker run --name forgejo -e FORGEJO__security__INSTALL_LOCK=true \ -d codeberg.org/forgejo/forgejo:1.19 (cherry picked from commit 6cd61e2ab701ae9236ff9a68520ee1e2d03e6193) (cherry picked from commit 62cae8cc6a6ddc9e5bb066c81834b75cef3be29f) (cherry picked from commit aee1afc5097531b2740b2aa8ef4aef745e7a1be0) (cherry picked from commit 6ba563cd9b09d012a804f3f438c5ae4e38ca6ced) (cherry picked from commit 6429b20f4a1561480a4a0c214cc571f79c313be0) (cherry picked from commit dd545aa077e21616b406d765b19a75df643a9695) (cherry picked from commit 63a00e573e2d6b6bfb75d28a816327435bace02d) (cherry picked from commit 8e35a50b91fcec0b27b6b5458facb12e9bda8505) (cherry picked from commit 26e8fb6cd953a6c9dfae89b430856895c7253a7c) (cherry picked from commit 56bbf644beb25f62964b2c0c847d7b9d711ed56e) (cherry picked from commit 4d0a8c8640fee94ddffad2250ce5619d4894d3d3) (cherry picked from commit b58f775fa22116334d5e0d7114c5d37d96693471) (cherry picked from commit f4b6fa7a937cb4bfcb3623d4e13fce76e76c069e) (cherry picked from commit 4eca3630826d5cbf9e11156f84434ad7fad1c88b) (cherry picked from commit e2e7a72f804ec67b1e3c0eba15eb507f47711806) (cherry picked from commit 00ce992957a6797124310826675db2dde0f450af) (cherry picked from commit 971b26ec1c1e8cda6eef44d27eb33dbb0982e77c) (cherry picked from commit dd2f0046bdf68e4f8cd14001e4f1fc82d720b080)
2023-01-12 22:56:56 +01:00
// Copyright 2023 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package main
import (
"regexp"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_splitEnvironmentVariable(t *testing.T) {
prefixRegexp := regexp.MustCompile(EnvironmentPrefix + "__")
k, v := splitEnvironmentVariable(prefixRegexp, "FORGEJO__KEY=VALUE")
assert.Equal(t, k, "KEY")
assert.Equal(t, v, "VALUE")
k, v = splitEnvironmentVariable(prefixRegexp, "nothing=interesting")
assert.Equal(t, k, "")
assert.Equal(t, v, "")
}