@@ -3,6 +3,7 @@ package catalog
33import (
44 "testing"
55
6+ "github.com/databricks/databricks-sdk-go/apierr"
67 "github.com/databricks/databricks-sdk-go/service/catalog"
78 "github.com/databricks/terraform-provider-databricks/qa"
89)
@@ -532,3 +533,96 @@ func TestUpdateAccountMetastore_DeltaSharingScopeOnly(t *testing.T) {
532533 ` ,
533534 }.ApplyNoError (t )
534535}
536+
537+ func TestReadAccountMetastore (t * testing.T ) {
538+ qa.ResourceFixture {
539+ Fixtures : []qa.HTTPFixture {
540+ {
541+ Method : "GET" ,
542+ Resource : "/api/2.0/accounts/100/metastores/abc?" ,
543+ Response : catalog.AccountsMetastoreInfo {
544+ MetastoreInfo : & catalog.MetastoreInfo {
545+ StorageRoot : "s3://b/abc" ,
546+ Name : "a" ,
547+ Region : "us-east1" ,
548+ },
549+ },
550+ },
551+ },
552+ Resource : ResourceMetastore (),
553+ AccountID : "100" ,
554+ ID : "abc" ,
555+ Read : true ,
556+ New : true ,
557+ }.ApplyAndExpectData (t ,
558+ map [string ]any {
559+ "id" : "abc" ,
560+ "storage_root" : "s3://b/abc" ,
561+ "name" : "a" ,
562+ "region" : "us-east1" ,
563+ })
564+ }
565+
566+ func TestReadAccountMetastore_Error (t * testing.T ) {
567+ qa.ResourceFixture {
568+ Fixtures : []qa.HTTPFixture {
569+ {
570+ Method : "GET" ,
571+ Resource : "/api/2.0/accounts/100/metastores/abc?" ,
572+ Response : apierr.APIErrorBody {
573+ ErrorCode : "RESOURCE_DOES_NOT_EXIST" ,
574+ Message : "Metastore with the given ID could not be found." ,
575+ },
576+ Status : 404 ,
577+ },
578+ },
579+ Resource : ResourceMetastore (),
580+ AccountID : "100" ,
581+ ID : "abc" ,
582+ Read : true ,
583+ }.ExpectError (t , "resource is not expected to be removed" )
584+ }
585+
586+ func TestReadMetastore (t * testing.T ) {
587+ qa.ResourceFixture {
588+ Fixtures : []qa.HTTPFixture {
589+ {
590+ Method : "GET" ,
591+ Resource : "/api/2.1/unity-catalog/metastores/abc?" ,
592+ Response : catalog.MetastoreInfo {
593+ StorageRoot : "s3://b/abc" ,
594+ Name : "a" ,
595+ },
596+ },
597+ },
598+ Resource : ResourceMetastore (),
599+ ID : "abc" ,
600+ Read : true ,
601+ New : true ,
602+ }.ApplyAndExpectData (t ,
603+ map [string ]any {
604+ "id" : "abc" ,
605+ "storage_root" : "s3://b/abc" ,
606+ "name" : "a" ,
607+ })
608+ }
609+
610+ func TestReadMetastore_Error (t * testing.T ) {
611+ qa.ResourceFixture {
612+ Fixtures : []qa.HTTPFixture {
613+ {
614+ Method : "GET" ,
615+ Resource : "/api/2.1/unity-catalog/metastores/abc?" ,
616+ Response : apierr.APIErrorBody {
617+ ErrorCode : "RESOURCE_DOES_NOT_EXIST" ,
618+ Message : "Metastore with the given ID could not be found." ,
619+ },
620+ Status : 404 ,
621+ },
622+ },
623+ Resource : ResourceMetastore (),
624+ ID : "abc" ,
625+ Read : true ,
626+ New : true ,
627+ }.ExpectError (t , "resource is not expected to be removed" )
628+ }
0 commit comments