From a623b98b172294d5083460652a6e080efec586c6 Mon Sep 17 00:00:00 2001 From: imjoey Date: Mon, 18 Jan 2021 15:55:34 +0800 Subject: [PATCH] Fix missing return obj when create-if-not-exist Signed-off-by: imjoey --- api/internal/core/store/store.go | 3 +-- api/test/e2e/ssl_test.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api/internal/core/store/store.go b/api/internal/core/store/store.go index 295f6a297c..8a97c37edf 100644 --- a/api/internal/core/store/store.go +++ b/api/internal/core/store/store.go @@ -284,8 +284,7 @@ func (s *GenericStore) Update(ctx context.Context, obj interface{}, createIfNotE storedObj, ok := s.cache.Load(key) if !ok { if createIfNotExist { - _, err := s.Create(ctx, obj) - return nil, err + return s.Create(ctx, obj) } log.Warnf("key: %s is not found", key) return nil, fmt.Errorf("key: %s is not found", key) diff --git a/api/test/e2e/ssl_test.go b/api/test/e2e/ssl_test.go index f5f51c4cd7..add2e667fd 100644 --- a/api/test/e2e/ssl_test.go +++ b/api/test/e2e/ssl_test.go @@ -131,7 +131,7 @@ func TestSSL_Basic(t *testing.T) { }`, Headers: map[string]string{"Authorization": token}, ExpectStatus: http.StatusOK, - ExpectBody: "\"status\": 0", + ExpectBody: "\"status\":0", }, } @@ -156,7 +156,7 @@ func TestSSL_Basic(t *testing.T) { Body: `1`, Headers: map[string]string{"Authorization": token}, ExpectStatus: http.StatusOK, - ExpectBody: "\"status\": 1", + ExpectBody: "\"status\":1", }, { Desc: "hit the route using HTTPS, make sure enable successful",