(t *testing.T)
| 72 | } |
| 73 | |
| 74 | func TestConfigFromEnvInvalidOverride(t *testing.T) { |
| 75 | tests := []struct { |
| 76 | name string |
| 77 | key string |
| 78 | value string |
| 79 | }{ |
| 80 | {name: "invalid access lifetime", key: "GH_INTERNAL_AT_EXPIRES_IN", value: "invalid"}, |
| 81 | {name: "invalid refresh lifetime", key: "GH_INTERNAL_RT_EXPIRES_IN", value: "invalid"}, |
| 82 | {name: "fractional seconds", key: "GH_INTERNAL_AT_EXPIRES_IN", value: "1.5"}, |
| 83 | {name: "duration overflow", key: "GH_INTERNAL_AT_EXPIRES_IN", value: "9223372037"}, |
| 84 | {name: "duration underflow", key: "GH_INTERNAL_AT_EXPIRES_IN", value: "-9223372037"}, |
| 85 | {name: "integer overflow", key: "GH_INTERNAL_RT_EXPIRES_IN", value: "9223372036854775808"}, |
| 86 | {name: "empty lifetime", key: "GH_INTERNAL_AT_EXPIRES_IN", value: ""}, |
| 87 | {name: "invalid boolean", key: "GH_INTERNAL_DEBUG_REFRESH_TOKEN", value: "enabled"}, |
| 88 | {name: "empty boolean", key: "GH_INTERNAL_DEBUG_REFRESH_TOKEN", value: ""}, |
| 89 | } |
| 90 | for _, tt := range tests { |
| 91 | t.Run(tt.name, func(t *testing.T) { |
| 92 | clearConfigEnv(t) |
| 93 | t.Setenv(tt.key, tt.value) |
| 94 | |
| 95 | require.Panics(t, func() { |
| 96 | configFromEnv() |
| 97 | }) |
| 98 | }) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // clearConfigEnv unsets the debug variables for the test, so cases expecting no override are not affected by the |
| 103 | // environment running the tests. t.Setenv registers the restore before the variable is unset. |
nothing calls this directly
no test coverage detected