mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-19 20:17:30 +02:00
auto tls (#3856)
This commit is contained in:
parent
78fc4853db
commit
488bcd6f72
12 changed files with 447 additions and 67 deletions
|
@ -1,8 +1,15 @@
|
|||
package fileutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestIsReadableFile(t *testing.T) {
|
||||
|
@ -45,3 +52,29 @@ func TestGetwd(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadFileUpTo(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
input := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
fname := path.Join(d, "test")
|
||||
require.NoError(t, os.WriteFile(fname, input, 0600))
|
||||
|
||||
for _, tc := range []struct {
|
||||
size int
|
||||
expectError bool
|
||||
}{
|
||||
{len(input) - 1, true},
|
||||
{len(input), false},
|
||||
{len(input) + 1, false},
|
||||
} {
|
||||
t.Run(fmt.Sprint(tc), func(t *testing.T) {
|
||||
out, err := ReadFileUpTo(fname, int64(tc.size))
|
||||
if tc.expectError {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
assert.True(t, bytes.Equal(input, out))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue