From b628ab9dd0ba34e000feb2706f2ccaa38bffd813 Mon Sep 17 00:00:00 2001 From: Gustavo Bazan Date: Fri, 26 Jan 2024 17:58:17 +0000 Subject: [PATCH] CLOUDP-226164: Fix clusters tests to use the new SDK (#2570) --- internal/cli/atlas/accesslogs/list_test.go | 4 ++++ internal/cli/atlas/clusters/list_test.go | 15 ++++++++++----- .../cli/atlas/datalakepipelines/create_test.go | 4 +--- test/e2e/atlas/helper_test.go | 1 - 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/internal/cli/atlas/accesslogs/list_test.go b/internal/cli/atlas/accesslogs/list_test.go index 018e0e7e4c..a7135eb812 100644 --- a/internal/cli/atlas/accesslogs/list_test.go +++ b/internal/cli/atlas/accesslogs/list_test.go @@ -72,6 +72,10 @@ func TestAccessLogListClusterName_Run(t *testing.T) { test.VerifyOutputTemplate(t, listTemplate, expected) } +func TestListTemplate(t *testing.T) { + test.VerifyOutputTemplate(t, listTemplate, atlasv2.MongoDBAccessLogsList{}) +} + func TestAccessLogListHostname_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockAccessLogsLister(ctrl) diff --git a/internal/cli/atlas/clusters/list_test.go b/internal/cli/atlas/clusters/list_test.go index 9aecf9d093..e18f832903 100644 --- a/internal/cli/atlas/clusters/list_test.go +++ b/internal/cli/atlas/clusters/list_test.go @@ -22,19 +22,20 @@ import ( "github.com/golang/mock/gomock" "github.com/mongodb/mongodb-atlas-cli/internal/flag" "github.com/mongodb/mongodb-atlas-cli/internal/mocks" + "github.com/mongodb/mongodb-atlas-cli/internal/pointer" "github.com/mongodb/mongodb-atlas-cli/internal/test" - "go.mongodb.org/atlas/mongodbatlas" + "go.mongodb.org/atlas-sdk/v20231115002/admin" ) func TestList_Run(t *testing.T) { ctrl := gomock.NewController(t) mockStore := mocks.NewMockClusterLister(ctrl) - expected := mongodbatlas.AdvancedClustersResponse{ - Results: []*mongodbatlas.AdvancedCluster{ + expected := admin.PaginatedAdvancedClusterDescription{ + Results: []admin.AdvancedClusterDescription{ { - Name: "test", - ID: "123", + Name: pointer.Get("test"), + Id: pointer.Get("123"), }, }, } @@ -54,6 +55,10 @@ func TestList_Run(t *testing.T) { } } +func TestListTemplate(t *testing.T) { + test.VerifyOutputTemplate(t, listTemplate, admin.PaginatedAdvancedClusterDescription{}) +} + func TestListBuilder(t *testing.T) { test.CmdValidator( t, diff --git a/internal/cli/atlas/datalakepipelines/create_test.go b/internal/cli/atlas/datalakepipelines/create_test.go index 95df2a2c0a..397b2866ab 100644 --- a/internal/cli/atlas/datalakepipelines/create_test.go +++ b/internal/cli/atlas/datalakepipelines/create_test.go @@ -47,9 +47,7 @@ func TestCreate_Run(t *testing.T) { CreatePipeline(createOpts.ConfigProjectID(), *request).Return(expected, nil). Times(1) - if err := createOpts.Run(); err != nil { - t.Fatalf("Run() unexpected error: %v", err) - } + require.NoError(t, createOpts.Run()) } func TestCreateBuilder(t *testing.T) { diff --git a/test/e2e/atlas/helper_test.go b/test/e2e/atlas/helper_test.go index 93d34c21d6..c861d6f10b 100644 --- a/test/e2e/atlas/helper_test.go +++ b/test/e2e/atlas/helper_test.go @@ -41,7 +41,6 @@ const ( metricsEntity = "metrics" searchEntity = "search" indexEntity = "index" - datalakeEntity = "datalake" datafederationEntity = "datafederation" datalakePipelineEntity = "datalakepipeline" alertsEntity = "alerts"