Initial import
This commit is contained in:
60
env_test.go
Normal file
60
env_test.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package secret
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEnvironment(t *testing.T) {
|
||||
testProvider(t, Environment(),
|
||||
testProviderCase{
|
||||
Key: "USER",
|
||||
Test: testNotEmpty,
|
||||
})
|
||||
}
|
||||
|
||||
func TestEnvironmentPrefix(t *testing.T) {
|
||||
testProvider(t, EnvironmentPrefix("US"),
|
||||
testProviderCase{
|
||||
Key: "ER",
|
||||
Test: testNotEmpty,
|
||||
})
|
||||
}
|
||||
|
||||
var testEnvironmentFileCases = []testProviderCase{
|
||||
{
|
||||
Key: "test",
|
||||
Test: testEqualString("case"),
|
||||
},
|
||||
{
|
||||
Key: "spaces",
|
||||
Test: testEqualString("yeah"),
|
||||
},
|
||||
{
|
||||
Key: "ignored",
|
||||
Err: NotFound{"ignored"},
|
||||
},
|
||||
}
|
||||
|
||||
func TestEnvironmentFile(t *testing.T) {
|
||||
p, err := EnvironmentFile(filepath.Join("testdata", "env"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
testProvider(t, p, testEnvironmentFileCases...)
|
||||
}
|
||||
|
||||
func TestEnvironmentReader(t *testing.T) {
|
||||
p, err := EnvironmentReader(bytes.NewBufferString(`
|
||||
#ignored=true
|
||||
test=case
|
||||
spaces = yeah
|
||||
`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
testProvider(t, p, testEnvironmentFileCases...)
|
||||
}
|
Reference in New Issue
Block a user