MCPcopy Index your code
hub / github.com/GoogleCloudPlatform/cloud-sql-proxy / TestNewCommandWithEnvironmentConfig

Function TestNewCommandWithEnvironmentConfig

cmd/root_test.go:607–894  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

605}
606
607func TestNewCommandWithEnvironmentConfig(t *testing.T) {
608 tcs := []struct {
609 desc string
610 envName string
611 envValue string
612 want *proxy.Config
613 }{
614 {
615 desc: "using the address envvar",
616 envName: "CSQL_PROXY_ADDRESS",
617 envValue: "0.0.0.0",
618 want: withDefaults(&proxy.Config{
619 Addr: "0.0.0.0",
620 }),
621 },
622 {
623 desc: "using the port envvar",
624 envName: "CSQL_PROXY_PORT",
625 envValue: "6000",
626 want: withDefaults(&proxy.Config{
627 Port: 6000,
628 }),
629 },
630 {
631 desc: "using the token envvar",
632 envName: "CSQL_PROXY_TOKEN",
633 envValue: "MYCOOLTOKEN",
634 want: withDefaults(&proxy.Config{
635 Token: "MYCOOLTOKEN",
636 }),
637 },
638 {
639 desc: "using the credentiale file envvar",
640 envName: "CSQL_PROXY_CREDENTIALS_FILE",
641 envValue: "/path/to/file",
642 want: withDefaults(&proxy.Config{
643 CredentialsFile: "/path/to/file",
644 }),
645 },
646 {
647 desc: "using the JSON credentials",
648 envName: "CSQL_PROXY_JSON_CREDENTIALS",
649 envValue: `{"json":"goes-here"}`,
650 want: withDefaults(&proxy.Config{
651 CredentialsJSON: `{"json":"goes-here"}`,
652 }),
653 },
654 {
655 desc: "using the gcloud auth envvar",
656 envName: "CSQL_PROXY_GCLOUD_AUTH",
657 envValue: "true",
658 want: withDefaults(&proxy.Config{
659 GcloudAuth: true,
660 }),
661 },
662 {
663 desc: "using the api-endpoint envvar",
664 envName: "CSQL_PROXY_SQLADMIN_API_ENDPOINT",

Callers

nothing calls this directly

Calls 2

withDefaultsFunction · 0.85
invokeProxyCommandFunction · 0.85

Tested by

no test coverage detected