(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func 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 | |
| 99 | func TestEnvOrElse(t *testing.T) { |
| 100 | t.Run("envOrElse should return else value when env var is not present", func(t *testing.T) { |
nothing calls this directly
no test coverage detected