MCPcopy Index your code
hub / github.com/coder/coder / TestServer_TelemetryDisable

Function TestServer_TelemetryDisable

cli/server_test.go:2172–2201  ·  view source on GitHub ↗

nolint:tparallel,paralleltest // This test sets environment variables.

(t *testing.T)

Source from the content-addressed store, hash-verified

2170
2171//nolint:tparallel,paralleltest // This test sets environment variables.
2172func 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.
2204func TestServer_InterruptShutdown(t *testing.T) {

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
RunFunction · 0.92
SetenvMethod · 0.80
RunMethod · 0.65
SetMethod · 0.65
UnmarshalMethod · 0.45
BytesMethod · 0.45
EqualMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected