File: logger_test.go

package info (click to toggle)
golang-github-pterm-pterm 0.12.79-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,640 kB
  • sloc: makefile: 4
file content (41 lines) | stat: -rw-r--r-- 811 bytes parent folder | download
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
41
package pterm

import (
	"reflect"
	"testing"
)

func Test_sanitizeArgs(t *testing.T) {
	tests := []struct {
		name     string
		args     []any
		expected []any
	}{
		{
			name:     "pass_zero_args",
			args:     []any{},
			expected: []any{},
		},
		{
			name:     "pass_one_arg",
			args:     []any{"foo"},
			expected: []any{ErrKeyWithoutValue, "foo"},
		},
		{
			name:     "pass_two_args",
			args:     []any{"foo", "bar"},
			expected: []any{"foo", "bar"},
		},
		{
			name:     "pass_three_args",
			args:     []any{"foo", "bar", "baz"},
			expected: []any{"foo", "bar", ErrKeyWithoutValue, "baz"},
		},
	}
	l := Logger{}
	for _, tt := range tests {
		if got := l.sanitizeArgs(tt.args); !reflect.DeepEqual(got, tt.expected) {
			t.Errorf("sanitizeArgs: got: %v, expected: %v", got, tt.expected)
		}
	}
}