MCPcopy Create free account
hub / github.com/coder/coder / TestNormalizedEnumValue

Function TestNormalizedEnumValue

coderd/x/chatd/chatutil/chatutil_test.go:40–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestNormalizedEnumValue(t *testing.T) {
41 t.Parallel()
42
43 tests := []struct {
44 name string
45 value string
46 allowed []string
47 want *string
48 }{
49 {
50 name: "MatchFound",
51 value: "medium",
52 allowed: []string{"Low", "Medium", "High"},
53 want: ptr("Medium"),
54 },
55 {
56 name: "MatchMissing",
57 value: "maximum",
58 allowed: []string{"Low", "Medium", "High"},
59 },
60 }
61
62 for _, tt := range tests {
63 t.Run(tt.name, func(t *testing.T) {
64 t.Parallel()
65
66 got := chatutil.NormalizedEnumValue(tt.value, tt.allowed...)
67 if tt.want == nil {
68 require.Nil(t, got)
69 return
70 }
71 require.NotNil(t, got)
72 require.Equal(t, *tt.want, *got)
73 })
74 }
75}
76
77func ptr[T any](value T) *T {
78 return &value

Callers

nothing calls this directly

Calls 4

NormalizedEnumValueFunction · 0.92
ptrFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected