MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestSpoolStdinToTemp_Success

Function TestSpoolStdinToTemp_Success

cmd/stdin_test.go:13–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestSpoolStdinToTemp_Success(t *testing.T) {
14 data := []byte("hello from stdin")
15 r := bytes.NewReader(data)
16
17 path, size, cleanup, err := spoolStdinToTemp(r)
18 if err != nil {
19 t.Fatalf("unexpected error: %v", err)
20 }
21 defer func() { _ = cleanup() }()
22
23 if size != int64(len(data)) {
24 t.Errorf("size = %d, want %d", size, len(data))
25 }
26
27 got, err := os.ReadFile(path)
28 if err != nil {
29 t.Fatalf("failed to read temp file: %v", err)
30 }
31 if !bytes.Equal(got, data) {
32 t.Errorf("temp file content = %q, want %q", got, data)
33 }
34
35 info, err := os.Stat(path)
36 if err != nil {
37 t.Fatalf("failed to stat temp file: %v", err)
38 }
39 if runtime.GOOS != "windows" && info.Mode().Perm() != 0600 {
40 t.Errorf("temp file permissions = %o, want 0600", info.Mode().Perm())
41 }
42}
43
44func TestSpoolStdinToTemp_Empty(t *testing.T) {
45 r := bytes.NewReader(nil)

Callers

nothing calls this directly

Calls 1

spoolStdinToTempFunction · 0.85

Tested by

no test coverage detected