MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / TestReadToken_FromStdin

Function TestReadToken_FromStdin

internal/nodeenroll/cmd_test.go:96–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func TestReadToken_FromStdin(t *testing.T) {
97 r, w, err := os.Pipe()
98 if err != nil {
99 t.Fatal(err)
100 }
101 orig := os.Stdin
102 os.Stdin = r
103 defer func() { os.Stdin = orig }()
104
105 go func() {
106 _, _ = w.Write([]byte("stdin-token\n"))
107 _ = w.Close()
108 }()
109
110 got, err := readToken("-")
111 if err != nil {
112 t.Fatal(err)
113 }
114 if got != "stdin-token" {
115 t.Errorf("got %q", got)
116 }
117}

Callers

nothing calls this directly

Calls 3

readTokenFunction · 0.85
WriteMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected