forgejo/contrib/environment-to-ini/environment-to-ini_test.go
Earl Warren c147a1894d
[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.18

Signed-off-by: Earl Warren <contact@earl-warren.org>
(cherry picked from commit 6cd61e2ab701ae9236ff9a68520ee1e2d03e6193)
(cherry picked from commit 62cae8cc6a6ddc9e5bb066c81834b75cef3be29f)
(cherry picked from commit aee1afc5097531b2740b2aa8ef4aef745e7a1be0)
(cherry picked from commit 6ba563cd9b09d012a804f3f438c5ae4e38ca6ced)
(cherry picked from commit d887235e08)
(cherry picked from commit c9a0a44e28237a0b1ff3c65abc5b078383cdf4ac)
(cherry picked from commit 2cae2fca8e)
(cherry picked from commit c457919a2a)
(cherry picked from commit 57709acf65)
(cherry picked from commit 5bad53d6fc)
2023-05-10 11:05:22 +02:00

21 lines
539 B
Go

// 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(prefixRegexpString + "__")
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, "")
}