From d91a5e619f07d7937a066378bc04886d82017e39 Mon Sep 17 00:00:00 2001 From: Drew Bailey <2614075+drewbailey@users.noreply.github.com> Date: Fri, 8 Nov 2019 15:49:04 -0500 Subject: [PATCH] update test --- api/allocations_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/allocations_test.go b/api/allocations_test.go index b942ee0e0..4f9ab4501 100644 --- a/api/allocations_test.go +++ b/api/allocations_test.go @@ -2,6 +2,7 @@ package api import ( "context" + "fmt" "os" "reflect" "sort" @@ -265,8 +266,10 @@ func TestAllocations_ExecErrors(t *testing.T) { } job.Canonicalize() + allocID := uuid.Generate() + alloc := &Allocation{ - ID: "", + ID: allocID, Namespace: DefaultNamespace, EvalID: uuid.Generate(), Name: "foo-bar[1]", @@ -280,9 +283,10 @@ func TestAllocations_ExecErrors(t *testing.T) { // make a request that will result in an error // ensure the error is what we expect - _, err := a.Exec(context.Background(), alloc, "bar", false, []string{"command"}, os.Stdin, os.Stdout, os.Stderr, sizeCh, nil) - require.Contains(t, err.Error(), "Unexpected response code: 301") - require.Contains(t, err.Error(), "Moved Permanently") + exitCode, err := a.Exec(context.Background(), alloc, "bar", false, []string{"command"}, os.Stdin, os.Stdout, os.Stderr, sizeCh, nil) + + require.Equal(t, exitCode, -2) + require.Equal(t, err.Error(), fmt.Sprintf("Unknown allocation \"%s\"", allocID)) } func TestAllocations_ShouldMigrate(t *testing.T) {