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