github.com/go-chef/chef@v0.30.1/required_recipe_test.go (about) 1 package chef 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 ) 8 9 func TestRequiredRecipeGet(t *testing.T) { 10 setup() 11 defer teardown() 12 13 recipeText := "file 'test'" 14 mux.HandleFunc("/required_recipe", func(w http.ResponseWriter, r *http.Request) { 15 w.Header().Add("Content-Type", "text/plain") 16 fmt.Fprintf(w, recipeText) 17 }) 18 19 wantRecipe := RequiredRecipe(recipeText) 20 21 recipe, err := client.RequiredRecipe.Get() 22 if err != nil { 23 t.Errorf("RequiredRecipe.Get returned error: %s", err.Error()) 24 } 25 26 if recipe != wantRecipe { 27 t.Errorf("RequiredRecipe.Get returned %+v, want %+v, error %+v", recipe, wantRecipe, err) 28 } 29 30 }