MCPcopy
hub / github.com/dapr/dapr / TestGetIntValFromStringVal

Function TestGetIntValFromStringVal

utils/utils_test.go:68–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestGetIntValFromStringVal(t *testing.T) {
69 tcs := []struct {
70 name string
71 val int
72 def int
73 expected int
74 }{
75 {
76 name: "value is not provided by user, default value is used",
77 val: 0,
78 def: 5,
79 expected: 5,
80 },
81 {
82 name: "val is provided by user",
83 val: 91,
84 def: 5,
85 expected: 91,
86 },
87 }
88
89 for _, tc := range tcs {
90 t.Run(tc.name, func(t *testing.T) {
91 actual := GetIntValOrDefault(tc.val, tc.def)
92 if actual != tc.expected {
93 t.Errorf("expected %d, actual %d", tc.expected, actual)
94 }
95 })
96 }
97}
98
99func TestEnvOrElse(t *testing.T) {
100 t.Run("envOrElse should return else value when env var is not present", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

GetIntValOrDefaultFunction · 0.85
ErrorfMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected