forgejo_backup/modules/templates/context_test.go
Gusted d4e4a2a1e3 chore: move template context (#8663)
The template module now holds the **Template** context, this makes it possible for (render) function in the template module to access functions and share data between render functions.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8663
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: Lucas <sclu1034@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
2025-07-25 11:55:15 +02:00

18 lines
442 B
Go

// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package templates
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestContext(t *testing.T) {
type ctxKey struct{}
// Test that the original context is used for its context functions.
ctx := NewContext(context.WithValue(t.Context(), ctxKey{}, "there"))
assert.Equal(t, "there", ctx.Value(ctxKey{}))
}