MCPcopy Create free account
hub / github.com/coder/coder / TestWithTerminalEnv

Function TestWithTerminalEnv

agent/reconnectingpty/reconnectingpty_internal_test.go:10–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestWithTerminalEnv(t *testing.T) {
11 t.Parallel()
12
13 defaultLocale := "C.UTF-8"
14 if runtime.GOOS == "darwin" {
15 defaultLocale = "UTF-8"
16 }
17
18 tests := []struct {
19 name string
20 env []string
21 wantLCCTYPE string
22 wantLCCTYPESet bool
23 }{
24 {
25 name: "adds locale when missing",
26 env: []string{"PATH=/bin"},
27 wantLCCTYPE: defaultLocale,
28 wantLCCTYPESet: true,
29 },
30 {
31 name: "adds locale when lang is not utf8",
32 env: []string{"LANG=C"},
33 wantLCCTYPE: defaultLocale,
34 wantLCCTYPESet: true,
35 },
36 {
37 name: "keeps utf8 lang",
38 env: []string{"LANG=C.UTF-8"},
39 },
40 {
41 name: "keeps unhyphenated utf8 lang",
42 env: []string{"LANG=C.UTF8"},
43 },
44 {
45 name: "keeps utf8 ctype",
46 env: []string{"LC_CTYPE=C.UTF-8"},
47 wantLCCTYPE: "C.UTF-8",
48 wantLCCTYPESet: true,
49 },
50 {
51 name: "overrides non utf8 ctype",
52 env: []string{"LANG=C.UTF-8", "LC_CTYPE=C"},
53 wantLCCTYPE: defaultLocale,
54 wantLCCTYPESet: true,
55 },
56 {
57 name: "keeps utf8 lc all",
58 env: []string{"LC_ALL=C.UTF-8"},
59 },
60 {
61 name: "preserves non empty lc all",
62 env: []string{"LC_ALL=C"},
63 },
64 {
65 name: "ignores empty lc all",
66 env: []string{"LC_ALL="},
67 wantLCCTYPE: defaultLocale,

Callers

nothing calls this directly

Calls 4

withTerminalEnvFunction · 0.85
envValueFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected