// Copyright (c) Alex Ellis 2017. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. package commands import ( "net/http" "regexp" "testing" "github.com/openfaas/faas-cli/test" ) func Test_deploy(t *testing.T) { s := test.MockHttpServer(t, []test.Request{ { Method: http.MethodPut, Uri: "/system/functions", ResponseStatusCode: http.StatusOK, }, }) defer s.Close() stdOut := test.CaptureStdout(func() { faasCmd.SetArgs([]string{ "deploy", "--gateway=" + s.URL, "--image=golang", "--name=test-function", }) faasCmd.Execute() }) if found, err := regexp.MatchString(`(?m:Deployed)`, stdOut); err != nil || !found { t.Fatalf("Output is not as expected:\n%s", stdOut) } if found, err := regexp.MatchString(`(?m:200 OK)`, stdOut); err != nil || !found { t.Fatalf("Output is not as expected:\n%s", stdOut) } }