nolint:tparallel,paralleltest // This test sets environment variables.
(t *testing.T)
| 2170 | |
| 2171 | //nolint:tparallel,paralleltest // This test sets environment variables. |
| 2172 | func TestServer_TelemetryDisable(t *testing.T) { |
| 2173 | // Set the default telemetry to true (normally disabled in tests). |
| 2174 | t.Setenv("CODER_TEST_TELEMETRY_DEFAULT_ENABLE", "true") |
| 2175 | |
| 2176 | for _, tt := range []struct { |
| 2177 | key string |
| 2178 | val string |
| 2179 | want bool |
| 2180 | }{ |
| 2181 | {"", "", true}, |
| 2182 | {"CODER_TELEMETRY_ENABLE", "true", true}, |
| 2183 | {"CODER_TELEMETRY_ENABLE", "false", false}, |
| 2184 | {"CODER_TELEMETRY", "true", true}, |
| 2185 | {"CODER_TELEMETRY", "false", false}, |
| 2186 | } { |
| 2187 | t.Run(fmt.Sprintf("%s=%s", tt.key, tt.val), func(t *testing.T) { |
| 2188 | t.Parallel() |
| 2189 | var b bytes.Buffer |
| 2190 | inv, _ := clitest.New(t, "server", "--write-config") |
| 2191 | inv.Stdout = &b |
| 2192 | inv.Environ.Set(tt.key, tt.val) |
| 2193 | clitest.Run(t, inv) |
| 2194 | |
| 2195 | var dv codersdk.DeploymentValues |
| 2196 | err := yaml.Unmarshal(b.Bytes(), &dv) |
| 2197 | require.NoError(t, err) |
| 2198 | assert.Equal(t, tt.want, dv.Telemetry.Enable.Value()) |
| 2199 | }) |
| 2200 | } |
| 2201 | } |
| 2202 | |
| 2203 | //nolint:tparallel,paralleltest // This test cannot be run in parallel due to signal handling. |
| 2204 | func TestServer_InterruptShutdown(t *testing.T) { |