mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-26 06:16:56 +09:00
Consolidate all Go tests. Coverage is identical to before. Go tests are around 5% faster while being 7% smaller. No non-test code is touched.
29 lines
583 B
Go
29 lines
583 B
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package filebuffer
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFileBackedBuffer(t *testing.T) {
|
|
for _, content := range []string{"test", "testtest"} {
|
|
buf := New(5, t.TempDir())
|
|
_, err := io.Copy(buf, strings.NewReader(content))
|
|
assert.NoError(t, err)
|
|
|
|
assert.EqualValues(t, len(content), buf.Size())
|
|
|
|
data, err := io.ReadAll(buf)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, content, string(data))
|
|
|
|
assert.NoError(t, buf.Close())
|
|
}
|
|
}
|