diff --git a/executor/api/grpc/server_test.go b/executor/api/grpc/server_test.go index 05f0664354..11e7e87c68 100644 --- a/executor/api/grpc/server_test.go +++ b/executor/api/grpc/server_test.go @@ -20,11 +20,11 @@ func TestAddPuid(t *testing.T) { func TestExistingPuid(t *testing.T) { g := NewGomegaWithT(t) - guid := "1" + puid := "1" - ctx := metadata.NewIncomingContext(context.TODO(), metadata.New(map[string]string{payload.SeldonPUIDHeader: guid})) + ctx := metadata.NewIncomingContext(context.TODO(), metadata.New(map[string]string{payload.SeldonPUIDHeader: puid})) meta := CollectMetadata(ctx) g.Expect(meta.Get(payload.SeldonPUIDHeader)).NotTo(BeNil()) - g.Expect(meta.Get(payload.SeldonPUIDHeader)[0]).To(Equal(guid)) + g.Expect(meta.Get(payload.SeldonPUIDHeader)[0]).To(Equal(puid)) } diff --git a/executor/predictor/predictor_process.go b/executor/predictor/predictor_process.go index 1fb0ef9bc5..15648377ce 100644 --- a/executor/predictor/predictor_process.go +++ b/executor/predictor/predictor_process.go @@ -14,6 +14,8 @@ import ( v1 "github.com/seldonio/seldon-core/operator/apis/machinelearning.seldon.io/v1" ) +const NilPUIDError = "context value for Seldon PUID Header is nil" + type PredictorProcess struct { Ctx context.Context Client client.SeldonApiClient @@ -270,7 +272,7 @@ func (p *PredictorProcess) getPUIDHeader() (string, error) { if puid, ok := p.Ctx.Value(payload.SeldonPUIDHeader).(string); ok { return puid, nil } - return "", fmt.Errorf("context value Seldon PUID Header is nil: interface to string conversion failed") + return "", fmt.Errorf(NilPUIDError) } func (p *PredictorProcess) Predict(node *v1.PredictiveUnit, msg payload.SeldonPayload) (payload.SeldonPayload, error) { diff --git a/executor/predictor/predictor_process_test.go b/executor/predictor/predictor_process_test.go index b295499b56..e43e6d2d84 100644 --- a/executor/predictor/predictor_process_test.go +++ b/executor/predictor/predictor_process_test.go @@ -472,5 +472,5 @@ func TestPredictNilPUIDError(t *testing.T) { graph := &v1.PredictiveUnit{} _, err := createPredictorProcessWithoutPUIDInContext(t).Predict(graph, createPredictPayload(g)) g.Expect(err).NotTo(BeNil()) - g.Expect(err.Error()).Should(Equal("context value Seldon PUID Header is nil: interface to string conversion failed")) + g.Expect(err.Error()).Should(Equal(NilPUIDError)) }