This commit is contained in:
Urko 2023-03-05 00:07:48 +01:00
parent 0bf7b63286
commit b049c6a779
2 changed files with 23 additions and 8 deletions

View File

@ -44,8 +44,14 @@ func TestNewWriter(t *testing.T) {
}
func Test_writer_WriteFile(t *testing.T) {
deleteAllDirs()
defer deleteAllDirs()
err := deleteAllDirs()
require.NoError(t, err)
defer func(t *testing.T) {
err := deleteAllDirs()
require.NoError(t, err)
}(t)
w := newWriter(testWriterPath)
wgot, err := w.WriteFile(testFileName, []byte(testFileContent))
require.NoError(t, err)
@ -57,18 +63,25 @@ func Test_writer_WriteFile(t *testing.T) {
}
func Test_writer_WriteFileError(t *testing.T) {
deleteAllDirs()
defer deleteAllDirs()
err := deleteAllDirs()
require.NoError(t, err)
defer func(t *testing.T) {
err := deleteAllDirs()
require.NoError(t, err)
}(t)
w := newWriter("")
_, err := w.WriteFile(testFileName, []byte(testFileContent))
_, err = w.WriteFile(testFileName, []byte(testFileContent))
assert.Error(t, err)
w = newWriter(testWriterPath)
_, err = w.WriteFile("", []byte(testFileContent))
require.Error(t, err)
go func() {
deleteAllDirs()
go func(t *testing.T) {
err := deleteAllDirs()
require.NoError(t, err)
for {
f, err := os.Stat(testWriterPath)
if err != nil {
@ -83,7 +96,7 @@ func Test_writer_WriteFileError(t *testing.T) {
require.NoError(t, err, "should not throw error because dir exists")
return
}
}()
}(t)
_, err = w.WriteFile(testFileName, nil)
assert.Error(t, err)

View File

@ -29,8 +29,10 @@ type Subject struct {
PostalCode string
}
/*
var (
subjectKeyId = []byte{1, 2, 3, 4, 6}
extKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth}
keyUsage = x509.KeyUsageDigitalSignature
)
*/