From 157f1a091bfd16c8d3ae0b5d05e2cc6ba60e69dc Mon Sep 17 00:00:00 2001 From: Chris Marchesi Date: Fri, 5 Nov 2021 14:05:52 -0700 Subject: [PATCH] internal/host/plugin: add update catalog test for empty/same description (#1672) This is to mainly get coverage on the empty description case, but it follows the same logic as the "update name to same" test. --- .../plugin/repository_host_catalog_test.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/internal/host/plugin/repository_host_catalog_test.go b/internal/host/plugin/repository_host_catalog_test.go index e0333af1bf..14f96af013 100644 --- a/internal/host/plugin/repository_host_catalog_test.go +++ b/internal/host/plugin/repository_host_catalog_test.go @@ -612,6 +612,14 @@ func TestRepository_UpdateCatalog(t *testing.T) { } } + checkUpdateCatalogRequestNewDescriptionNil := func() checkFunc { + return func(t *testing.T, ctx context.Context) { + t.Helper() + assert := assert.New(t) + assert.Nil(gotOnUpdateCatalogRequest.NewCatalog.Description) + } + } + checkUpdateCatalogRequestCurrentAttributes := func(want map[string]interface{}) checkFunc { return func(t *testing.T, ctx context.Context) { t.Helper() @@ -808,6 +816,23 @@ func TestRepository_UpdateCatalog(t *testing.T) { checkVerifyCatalogOplog(oplog.OpType_OP_TYPE_UPDATE), }, }, + { + name: "update description to same", + changeFuncs: []changeHostCatalogFunc{changeDescription("")}, + version: 2, + fieldMask: []string{"description"}, + wantCheckFuncs: []checkFunc{ + checkVersion(2), // Version remains same even though row is updated + checkUpdateCatalogRequestCurrentDescriptionNil(), + checkUpdateCatalogRequestNewDescriptionNil(), + checkDescription(""), + checkSecrets(map[string]interface{}{ + "one": "two", + }), + checkNumUpdated(1), + checkVerifyCatalogOplog(oplog.OpType_OP_TYPE_UPDATE), + }, + }, { name: "update attributes (add)", changeFuncs: []changeHostCatalogFunc{changeAttributes(map[string]interface{}{