38 lines
818 B
Go
38 lines
818 B
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*
|
|
* This work is published and licensed under a Creative Commons
|
|
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
|
*
|
|
* Distribution of this work is permitted, but commercial use and
|
|
* modifications are strictly prohibited.
|
|
*/
|
|
package repocli
|
|
|
|
import (
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"bytes"
|
|
"context"
|
|
"fmt"
|
|
"math/rand"
|
|
"testing"
|
|
)
|
|
|
|
func TestCopy(t *testing.T) {
|
|
srcsize := 1024 + 145
|
|
srcdata := make([]byte, srcsize)
|
|
_, err := rand.Read(srcdata)
|
|
require.NoError(t, err)
|
|
|
|
src := bytes.NewReader(srcdata)
|
|
dst := bytes.NewBuffer(nil)
|
|
|
|
ctx := context.Background()
|
|
recsize, err := Copy(ctx, dst, src)
|
|
require.NoError(t, err)
|
|
|
|
fmt.Printf("Size: %d %d\n", recsize, srcsize)
|
|
require.Equal(t, int64(srcsize), recsize)
|
|
}
|