Golang_HomeWork/hw07_file_copying/copy_test.go

28 lines
681 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCopy(t *testing.T) {
t.Run("Не существует исходный файл", func(t *testing.T) {
err := Copy("testdata/novalid.txt", "out.txt", 0, 0)
require.Equal(t, err, ErrNoInFile)
})
t.Run("Исходный файл является папкой", func(t *testing.T) {
err := Copy("testdata", "out.txt", 0, 0)
require.Equal(t, err, ErrThisIsDirectory)
})
t.Run("Офсет больше размера исходного файла", func(t *testing.T) {
err := Copy("testdata/input.txt", "out.txt", 8000, 0)
require.Equal(t, err, ErrOffsetExceedsFileSize)
})
}