feat(adapter): define Adapter interface and FileSet

This commit is contained in:
2026-05-23 02:45:50 +01:00
parent e4719b78a0
commit 6ab8d149e1
5 changed files with 175 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package secrets
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSubstituteSimple(t *testing.T) {
lookup := func(k string) (string, bool) {
if k == "FOO" {
return "bar", true
}
return "", false
}
out, err := Substitute("hello ${FOO}", lookup)
assert.NoError(t, err)
assert.Equal(t, "hello bar", out)
}
func TestSubstituteMissingStrict(t *testing.T) {
lookup := func(k string) (string, bool) { return "", false }
_, err := Substitute("${MISSING}", lookup)
assert.Error(t, err)
}
func TestSubstituteEscaped(t *testing.T) {
lookup := func(k string) (string, bool) { return "should-not-see", true }
out, err := Substitute("$${LITERAL}", lookup)
assert.NoError(t, err)
assert.Equal(t, "${LITERAL}", out)
}