github.com/tonto/cli@v0.0.0-20180104210444-aec958fa47db/routes_test.go (about) 1 package main 2 3 import ( 4 "net/http" 5 "os" 6 "testing" 7 8 "github.com/fnproject/cli/client" 9 ) 10 11 func TestEnvAsHeader(t *testing.T) { 12 const expectedValue = "v=v" 13 os.Setenv("k", expectedValue) 14 15 cases := [][]string{ 16 nil, 17 []string{}, 18 []string{"k"}, 19 } 20 for _, selectedEnv := range cases { 21 req, _ := http.NewRequest("GET", "http://www.example.com", nil) 22 client.EnvAsHeader(req, selectedEnv) 23 if found := req.Header.Get("k"); found != expectedValue { 24 t.Errorf("not found expected header: %v", found) 25 } 26 } 27 }