File: context_test.go

package info (click to toggle)
golang-github-zitadel-logging 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 156 kB
  • sloc: javascript: 8; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 372 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package logging

import (
	"context"
	"testing"

	"log/slog"

	"github.com/stretchr/testify/assert"
)

func TestContext(t *testing.T) {
	got, ok := FromContext(context.Background())
	assert.False(t, ok)
	assert.Nil(t, got)

	want := slog.Default()
	ctx := ToContext(context.Background(), want)
	got, ok = FromContext(ctx)
	assert.True(t, ok)
	assert.Equal(t, want, got)
}