Skip to content

Commit

Permalink
respect GAE_ENV=localdev
Browse files Browse the repository at this point in the history
  • Loading branch information
zevdg committed Jul 12, 2022
1 parent 0c7f7a8 commit be85e9f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/identity_vm.go
Expand Up @@ -131,5 +131,5 @@ func fullyQualifiedAppID(_ netcontext.Context) string {
}

func IsDevAppServer() bool {
return os.Getenv("RUN_WITH_DEVAPPSERVER") != ""
return os.Getenv("RUN_WITH_DEVAPPSERVER") != "" || os.Getenv("GAE_ENV") == "localdev"
}
2 changes: 1 addition & 1 deletion v2/internal/identity.go
Expand Up @@ -167,5 +167,5 @@ func fullyQualifiedAppID(_ netcontext.Context) string {
}

func IsDevAppServer() bool {
return os.Getenv("RUN_WITH_DEVAPPSERVER") != ""
return os.Getenv("RUN_WITH_DEVAPPSERVER") != "" || os.Getenv("GAE_ENV") == "localdev"
}
27 changes: 27 additions & 0 deletions v2/internal/identity_test.go
@@ -0,0 +1,27 @@
package internal

import (
"testing"
)

func TestIsDevAppServer(t *testing.T) {
tests := []struct {
desc string // See http://go/gotip/episodes/25 for naming guidance.
env map[string]string
want bool
}{
{desc: "empty", env: map[string]string{}, want: false},
{desc: "legacy", env: map[string]string{"RUN_WITH_DEVAPPSERVER": "1"}, want: true},
{desc: "new", env: map[string]string{"GAE_ENV": "localdev"}, want: true},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
for k, v := range test.env {
t.Setenv(k, v)
}
if got := IsDevAppServer(); got != test.want {
t.Errorf("env=%v IsDevAppServer() got %v, want %v", test.env, got, test.want)
}
})
}
}

0 comments on commit be85e9f

Please sign in to comment.