Files
got/httpdl/ca_test.go
2026-06-19 12:32:14 +09:00

23 lines
643 B
Go

package httpdl
import (
"os"
"path/filepath"
"testing"
)
func TestLoadCAPool(t *testing.T) {
// A missing file is an error, not a silent fall-back to the system roots.
if _, err := loadCAPool(filepath.Join(t.TempDir(), "absent.pem")); err == nil {
t.Errorf("loadCAPool(missing): want error")
}
// A file with no PEM certificates is an error (AppendCertsFromPEM found none).
bad := filepath.Join(t.TempDir(), "bad.pem")
if err := os.WriteFile(bad, []byte("not a certificate\n"), 0o644); err != nil {
t.Fatal(err)
}
if _, err := loadCAPool(bad); err == nil {
t.Errorf("loadCAPool(garbage): want error (no certificates)")
}
}