// Copyright 2026 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT package container import ( "bufio" "context" "os" "path/filepath" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func newTestHostEnv(t *testing.T) (*HostEnvironment, string) { t.Helper() e := &HostEnvironment{Path: t.TempDir()} return e, filepath.Join(e.Path, "envfile") } func TestParseEnvFileSingleLine(t *testing.T) { e, envPath := newTestHostEnv(t) require.NoError(t, os.WriteFile(envPath, []byte("FOO=bar\nBAZ=qux\n"), 0o600)) env := map[string]string{} require.NoError(t, parseEnvFile(e, envPath, &env)(context.Background())) assert.Equal(t, "bar", env["FOO"]) assert.Equal(t, "qux", env["BAZ"]) } func TestParseEnvFileMultiLine(t *testing.T) { e, envPath := newTestHostEnv(t) content := "FOO<