Adds `_internal_test.go` files to test unexported functions in the `crypt` and `lthn` packages, improving overall test coverage. - Adds tests for the `ensureRSA` private function in `pkg/crypt/crypt.go`. - Adds tests for the `createSalt` private function in `pkg/crypt/std/lthn/lthn.go`. These changes align with the project's TDD methodology and follow the `_Good`, `_Bad`, `_Ugly` testing structure.
24 lines
589 B
Go
24 lines
589 B
Go
package crypt
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestEnsureRSA_Good(t *testing.T) {
|
|
s := &Service{}
|
|
assert.Nil(t, s.rsa, "s.rsa should be nil initially")
|
|
s.ensureRSA()
|
|
assert.NotNil(t, s.rsa, "s.rsa should not be nil after ensureRSA()")
|
|
}
|
|
|
|
func TestEnsureRSA_Bad(t *testing.T) {
|
|
// Not really a "bad" case here in terms of invalid input,
|
|
// but we can test that calling it twice is safe.
|
|
s := &Service{}
|
|
s.ensureRSA()
|
|
rsaInstance := s.rsa
|
|
s.ensureRSA()
|
|
assert.Same(t, rsaInstance, s.rsa, "s.rsa should be the same instance after second call")
|
|
}
|