feedback and rebasing

This commit is contained in:
Alex Dadgar
2018-02-13 15:50:51 -08:00
parent e05cd42063
commit 4f332ff1c2
6 changed files with 22 additions and 24 deletions

View File

@@ -164,7 +164,7 @@ func (s *HTTPServer) allocGC(allocID string, resp http.ResponseWriter, req *http
}
if rpcErr != nil {
if structs.IsErrNoNodeConn(rpcErr) || strings.Contains(rpcErr.Error(), "unknown allocation") {
if structs.IsErrNoNodeConn(rpcErr) || structs.IsErrUnknownAllocation(rpcErr) {
rpcErr = CodedError(404, rpcErr.Error())
}
}
@@ -216,7 +216,7 @@ func (s *HTTPServer) allocStats(allocID string, resp http.ResponseWriter, req *h
}
if rpcErr != nil {
if structs.IsErrNoNodeConn(rpcErr) || strings.Contains(rpcErr.Error(), "unknown allocation") {
if structs.IsErrNoNodeConn(rpcErr) || structs.IsErrUnknownAllocation(rpcErr) {
rpcErr = CodedError(404, rpcErr.Error())
}
}

View File

@@ -277,7 +277,7 @@ func TestHTTP_AllocStats(t *testing.T) {
// Make the request
_, err = s.Server.ClientAllocRequest(respW, req)
require.NotNil(err)
require.Contains(err.Error(), "unknown allocation")
require.True(structs.IsErrUnknownAllocation(err))
}
// Local node, server resp
@@ -291,7 +291,7 @@ func TestHTTP_AllocStats(t *testing.T) {
respW := httptest.NewRecorder()
_, err = s.Server.ClientAllocRequest(respW, req)
require.NotNil(err)
require.Contains(err.Error(), "unknown allocation")
require.True(structs.IsErrUnknownAllocation(err))
s.server = srv
}
@@ -317,7 +317,7 @@ func TestHTTP_AllocStats(t *testing.T) {
respW := httptest.NewRecorder()
_, err = s.Server.ClientAllocRequest(respW, req)
require.NotNil(err)
require.Contains(err.Error(), "unknown allocation")
require.True(structs.IsErrUnknownAllocation(err))
s.client = c
}
@@ -551,7 +551,7 @@ func TestHTTP_AllocGC(t *testing.T) {
respW := httptest.NewRecorder()
_, err = s.Server.ClientAllocRequest(respW, req)
if err == nil || !strings.Contains(err.Error(), "unknown allocation") {
if !structs.IsErrUnknownAllocation(err) {
t.Fatalf("unexpected err: %v", err)
}
}
@@ -568,7 +568,7 @@ func TestHTTP_AllocGC(t *testing.T) {
respW := httptest.NewRecorder()
_, err = s.Server.ClientAllocRequest(respW, req)
if err == nil || !strings.Contains(err.Error(), "unknown allocation") {
if !structs.IsErrUnknownAllocation(err) {
t.Fatalf("unexpected err: %v", err)
}
@@ -598,7 +598,7 @@ func TestHTTP_AllocGC(t *testing.T) {
respW := httptest.NewRecorder()
_, err = s.Server.ClientAllocRequest(respW, req)
require.NotNil(err)
if err == nil || !strings.Contains(err.Error(), "unknown allocation") {
if !structs.IsErrUnknownAllocation(err) {
t.Fatalf("unexpected err: %v", err)
}