Audit: some refactoring out of types.go (#25511)

* some refactoring out of types.go

* tests for metrics tag, parallelize other tests
This commit is contained in:
Peter Wilson
2024-02-20 09:56:35 +00:00
committed by GitHub
parent 633dae1a6a
commit 808cdfc2d2
9 changed files with 160 additions and 72 deletions

View File

@@ -13,6 +13,8 @@ import (
// TestOptions_WithFormat exercises WithFormat Option to ensure it performs as expected.
func TestOptions_WithFormat(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value string
IsErrorExpected bool
@@ -68,6 +70,8 @@ func TestOptions_WithFormat(t *testing.T) {
// TestOptions_WithSubtype exercises WithSubtype Option to ensure it performs as expected.
func TestOptions_WithSubtype(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value string
IsErrorExpected bool
@@ -113,6 +117,8 @@ func TestOptions_WithSubtype(t *testing.T) {
// TestOptions_WithNow exercises WithNow Option to ensure it performs as expected.
func TestOptions_WithNow(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value time.Time
IsErrorExpected bool
@@ -154,6 +160,8 @@ func TestOptions_WithNow(t *testing.T) {
// TestOptions_WithID exercises WithID Option to ensure it performs as expected.
func TestOptions_WithID(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value string
IsErrorExpected bool
@@ -199,6 +207,8 @@ func TestOptions_WithID(t *testing.T) {
// TestOptions_WithPrefix exercises WithPrefix Option to ensure it performs as expected.
func TestOptions_WithPrefix(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value string
IsErrorExpected bool
@@ -244,6 +254,8 @@ func TestOptions_WithPrefix(t *testing.T) {
// TestOptions_WithRaw exercises WithRaw Option to ensure it performs as expected.
func TestOptions_WithRaw(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value bool
ExpectedValue bool
@@ -274,6 +286,8 @@ func TestOptions_WithRaw(t *testing.T) {
// TestOptions_WithElision exercises WithElision Option to ensure it performs as expected.
func TestOptions_WithElision(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value bool
ExpectedValue bool
@@ -304,6 +318,8 @@ func TestOptions_WithElision(t *testing.T) {
// TestOptions_WithHMACAccessor exercises WithHMACAccessor Option to ensure it performs as expected.
func TestOptions_WithHMACAccessor(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value bool
ExpectedValue bool
@@ -334,6 +350,8 @@ func TestOptions_WithHMACAccessor(t *testing.T) {
// TestOptions_WithOmitTime exercises WithOmitTime Option to ensure it performs as expected.
func TestOptions_WithOmitTime(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value bool
ExpectedValue bool
@@ -365,6 +383,8 @@ func TestOptions_WithOmitTime(t *testing.T) {
// TestOptions_WithHeaderFormatter exercises the WithHeaderFormatter Option to
// ensure it applies the option as expected under various circumstances.
func TestOptions_WithHeaderFormatter(t *testing.T) {
t.Parallel()
tests := map[string]struct {
Value HeaderFormatter
ExpectedValue HeaderFormatter
@@ -403,6 +423,8 @@ func TestOptions_WithHeaderFormatter(t *testing.T) {
// TestOptions_Default exercises getDefaultOptions to assert the default values.
func TestOptions_Default(t *testing.T) {
t.Parallel()
opts := getDefaultOptions()
require.NotNil(t, opts)
require.True(t, time.Now().After(opts.withNow))
@@ -411,6 +433,8 @@ func TestOptions_Default(t *testing.T) {
// TestOptions_Opts exercises GetOpts with various Option values.
func TestOptions_Opts(t *testing.T) {
t.Parallel()
tests := map[string]struct {
opts []Option
IsErrorExpected bool