github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/util/sysutil/large_file_test.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package sysutil 12 13 import ( 14 "io/ioutil" 15 "os" 16 "testing" 17 18 "github.com/cockroachdb/errors" 19 ) 20 21 func TestLargeFile(t *testing.T) { 22 f, err := ioutil.TempFile("", "input") 23 if err != nil { 24 t.Fatal(err) 25 } 26 fname := f.Name() 27 if err := f.Close(); err != nil { 28 t.Fatal(err) 29 } 30 const n int64 = 1013 31 if err := CreateLargeFile(fname, n); err != nil { 32 t.Fatal(err) 33 } 34 s, err := os.Stat(fname) 35 if err != nil { 36 t.Fatal(err) 37 } 38 if s.Size() != n { 39 t.Fatal(errors.Errorf("expected size of file %d, got %d", n, s.Size())) 40 } 41 }