cert, err := tls.LoadX509KeyPair(os.Getenv("CERT"), os.Getenv("KEY"))
if err != nil {
return err
}
I want to write a unit test for a function that contains this snippet of code. However, my test environment will never have any content in os.Getenv("CERT")
/os.Getenv("KEY")
. This makes the code(tls.LoadX509KeyPair()
) return an error, which doesn't let me test the function.
How should I go about mocking/modifying this snippet?