Panic on SSH agent errors in test
This commit is contained in:
@@ -3,6 +3,8 @@ package examples
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
|
"errors"
|
||||||
|
"io/fs"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -24,7 +26,10 @@ func sshagent() string {
|
|||||||
sock := filepath.Join(dir, "test.sock")
|
sock := filepath.Join(dir, "test.sock")
|
||||||
|
|
||||||
// In case it already exists.
|
// In case it already exists.
|
||||||
_ = os.Remove(sock)
|
err := os.Remove(sock)
|
||||||
|
if err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
l, err := net.Listen("unix", sock)
|
l, err := net.Listen("unix", sock)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -32,11 +37,14 @@ func sshagent() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
a := agent.NewKeyring()
|
a := agent.NewKeyring()
|
||||||
key, err := rsa.GenerateKey(rand.Reader, 2048)
|
key, err := rsa.GenerateKey(rand.Reader, 4096)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = a.Add(agent.AddedKey{PrivateKey: key})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
_ = a.Add(agent.AddedKey{PrivateKey: key})
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
conn, err := l.Accept()
|
conn, err := l.Accept()
|
||||||
|
|||||||
@@ -415,7 +415,6 @@ func TestImageDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "no diff if pull=true but no exports",
|
name: "no diff if pull=true but no exports",
|
||||||
olds: func(_ *testing.T, is ImageState) ImageState {
|
olds: func(_ *testing.T, is ImageState) ImageState {
|
||||||
fmt.Println("WHOA NELLY")
|
|
||||||
is.Pull = true
|
is.Pull = true
|
||||||
return is
|
return is
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user