File: regression_test.go

package info (click to toggle)
golang-github-zitadel-oidc 3.37.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 1,484 kB
  • sloc: makefile: 5
file content (40 lines) | stat: -rw-r--r-- 743 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package oidc

// This file contains common functions and data for regression testing

import (
	"encoding/json"
	"fmt"
	"io"
	"path"
	"strings"
	"testing"

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

const dataDir = "regression_data"

// jsonFilename builds a filename for the regression testdata.
// dataDir/<type_name>.json
func jsonFilename(obj any) string {
	name := fmt.Sprintf("%T.json", obj)
	return path.Join(
		dataDir,
		strings.TrimPrefix(name, "*"),
	)
}

func encodeJSON(t *testing.T, w io.Writer, obj any) {
	enc := json.NewEncoder(w)
	enc.SetIndent("", "\t")
	require.NoError(t, enc.Encode(obj))
}

var regressionData = []any{
	accessTokenData,
	idTokenData,
	introspectionResponseData,
	userInfoData,
	jwtProfileAssertionData,
}