36 lines
796 B
Go
36 lines
796 B
Go
package git_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.ar21.de/yolokube/grafana-backuper/pkg/git"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestReadKeyFile_Success(t *testing.T) {
|
|
signKey := &git.SignKey{KeyFile: "testdata/test-key.asc"}
|
|
err := signKey.ReadKeyFile()
|
|
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestReadKeyFile_FileError(t *testing.T) {
|
|
signKey := &git.SignKey{KeyFile: "nonexistent-file.asc"}
|
|
err := signKey.ReadKeyFile()
|
|
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestReadKeyFile_DecodingError(t *testing.T) {
|
|
signKey := &git.SignKey{KeyFile: "testdata/test-invalid-key.asc"}
|
|
err := signKey.ReadKeyFile()
|
|
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestReadKeyFile_EmptyKeyRing(t *testing.T) {
|
|
signKey := &git.SignKey{KeyFile: "testdata/test-empty-key.asc"}
|
|
err := signKey.ReadKeyFile()
|
|
|
|
assert.Error(t, err)
|
|
}
|