MCPcopy Create free account
hub / github.com/chain/txvm / TestInternalWriteRotate

Function TestInternalWriteRotate

log/rotation/file_test.go:116–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

114}
115
116func TestInternalWriteRotate(t *testing.T) {
117 defer os.Remove("x")
118 defer os.Remove("x.1")
119 os.Remove("x")
120 os.Remove("x.1")
121
122 f0, err := os.Create("x")
123 if err != nil {
124 t.Fatal(err)
125 }
126
127 f := &File{
128 base: "x",
129 n: 1,
130 size: 10,
131 w: 9,
132 f: f0,
133 }
134 b := []byte("abc\n")
135 n, err := f.write(b)
136 if err != nil {
137 t.Fatal(err)
138 }
139 if n != len(b) {
140 t.Fatalf("write(%q) = %d want %d", b, n, 4)
141 }
142 if !isRegular("x.1") {
143 t.Fatal("want rotated file x.1")
144 }
145 if f.f == f0 {
146 t.Fatal("want new file object")
147 }
148 if f.w != int64(len(b)) {
149 t.Fatalf("f.w = %d want %d", f.w, len(b))
150 }
151}
152
153func TestWrite(t *testing.T) {
154 defer os.Remove("x")

Callers

nothing calls this directly

Calls 2

writeMethod · 0.95
isRegularFunction · 0.85

Tested by

no test coverage detected