micro-tests/config/vault/vault_test.go
Vasiliy Tolstov 913249efed update all deps
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-01-16 02:49:58 +03:00

40 lines
821 B
Go

package vault_test
import (
"context"
"fmt"
"os"
"testing"
jsoncodec "github.com/unistack-org/micro-codec-json/v3"
vault "github.com/unistack-org/micro-config-vault/v3"
"github.com/unistack-org/micro/v3/config"
)
type Config struct {
Name string `json:"name"`
ContactEmail string `json:"contact_email"`
}
func TestLoad(t *testing.T) {
if len(os.Getenv("INTEGRATION_TESTS")) > 0 {
t.Skip()
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
conf := &Config{}
cfg := vault.NewConfig(config.Codec(jsoncodec.NewCodec()),
config.Struct(conf), vault.Path("/secret/data/customer/acme"), vault.Token("s.3QKHWXe4VV7S0wqIZuKxuEv0"))
if err := cfg.Init(); err != nil {
t.Fatal(err)
}
if err := cfg.Load(ctx); err != nil {
t.Fatal(err)
}
fmt.Printf("%#+v\n", conf)
}