Panic on SSH agent errors in test

This commit is contained in:
Bryce Lampe
2024-04-17 08:59:26 -07:00
parent 12788aca32
commit c8a3d26d9e
2 changed files with 11 additions and 4 deletions

View File

@@ -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()

View File

@@ -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
}, },