88 "github.com/google/go-cmp/cmp/cmpopts"
99 "github.com/google/uuid"
1010 "github.com/spf13/cobra"
11- "github.com/stackitcloud/stackit-sdk-go/services/intake"
11+ intake "github.com/stackitcloud/stackit-sdk-go/services/intake/v1betaapi "
1212
1313 "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1414 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
4141 // testCtx dummy context for testing purposes
4242 testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
4343 // testClient mock API client
44- testClient = & intake.APIClient {}
44+ testClient = & intake.APIClient {
45+ DefaultAPI : & intake.DefaultAPIService {},
46+ }
4547 testProjectId = uuid .NewString ()
4648 testRunnerId = uuid .NewString ()
4749
@@ -107,22 +109,22 @@ func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakePayload)) int
107109 authType := intake .CatalogAuthType (testCatalogAuthType )
108110 testPartitioningType := intake .PartitioningType (testCatalogPartitioning )
109111 payload := intake.CreateIntakePayload {
110- DisplayName : utils . Ptr ( testDisplayName ) ,
111- IntakeRunnerId : utils . Ptr ( testRunnerId ) ,
112+ DisplayName : testDisplayName ,
113+ IntakeRunnerId : testRunnerId ,
112114 Description : utils .Ptr (testDescription ),
113- Labels : utils . Ptr ( testLabels ) ,
114- Catalog : & intake.IntakeCatalog {
115- Uri : utils . Ptr ( testCatalogURI ) ,
116- Warehouse : utils . Ptr ( testCatalogWarehouse ) ,
115+ Labels : testLabels ,
116+ Catalog : intake.IntakeCatalog {
117+ Uri : testCatalogURI ,
118+ Warehouse : testCatalogWarehouse ,
117119 Namespace : utils .Ptr (testCatalogNamespace ),
118120 TableName : utils .Ptr (testCatalogTableName ),
119121 Partitioning : & testPartitioningType ,
120- PartitionBy : utils . Ptr ( testCatalogPartitionBy ) ,
122+ PartitionBy : testCatalogPartitionBy ,
121123 Auth : & intake.CatalogAuth {
122- Type : & authType ,
124+ Type : authType ,
123125 Dremio : & intake.DremioAuth {
124- TokenEndpoint : utils . Ptr ( testDremioTokenEndpoint ) ,
125- PersonalAccessToken : utils . Ptr ( testDremioToken ) ,
126+ TokenEndpoint : testDremioTokenEndpoint ,
127+ PersonalAccessToken : testDremioToken ,
126128 },
127129 },
128130 },
@@ -135,7 +137,7 @@ func fixtureCreatePayload(mods ...func(payload *intake.CreateIntakePayload)) int
135137
136138// fixtureRequest generates an API request for tests
137139func fixtureRequest (mods ... func (request * intake.ApiCreateIntakeRequest )) intake.ApiCreateIntakeRequest {
138- request := testClient .CreateIntake (testCtx , testProjectId , testRegion )
140+ request := testClient .DefaultAPI . CreateIntake (testCtx , testProjectId , testRegion )
139141 request = request .CreateIntakePayload (fixtureCreatePayload ())
140142 for _ , mod := range mods {
141143 mod (& request )
@@ -248,7 +250,7 @@ func TestBuildRequest(t *testing.T) {
248250 model .DremioToken = nil
249251 }),
250252 expectedRequest : fixtureRequest (func (request * intake.ApiCreateIntakeRequest ) {
251- * request = ( * request ) .CreateIntakePayload (fixtureCreatePayload (func (payload * intake.CreateIntakePayload ) {
253+ * request = request .CreateIntakePayload (fixtureCreatePayload (func (payload * intake.CreateIntakePayload ) {
252254 payload .Description = nil
253255 payload .Labels = nil
254256 payload .Catalog .Namespace = nil
@@ -267,9 +269,9 @@ func TestBuildRequest(t *testing.T) {
267269 model .DremioToken = nil
268270 }),
269271 expectedRequest : fixtureRequest (func (request * intake.ApiCreateIntakeRequest ) {
270- * request = ( * request ) .CreateIntakePayload (fixtureCreatePayload (func (payload * intake.CreateIntakePayload ) {
272+ * request = request .CreateIntakePayload (fixtureCreatePayload (func (payload * intake.CreateIntakePayload ) {
271273 authType := intake .CatalogAuthType ("none" )
272- payload .Catalog .Auth .Type = & authType
274+ payload .Catalog .Auth .Type = authType
273275 payload .Catalog .Auth .Dremio = nil
274276 }))
275277 }),
@@ -282,6 +284,7 @@ func TestBuildRequest(t *testing.T) {
282284 diff := cmp .Diff (request , tt .expectedRequest ,
283285 cmp .AllowUnexported (tt .expectedRequest ),
284286 cmpopts .EquateComparable (testCtx ),
287+ cmpopts .EquateComparable (testClient .DefaultAPI ),
285288 )
286289 if diff != "" {
287290 t .Fatalf ("Data does not match: %s" , diff )
@@ -306,7 +309,7 @@ func TestOutputResult(t *testing.T) {
306309 args : args {
307310 model : fixtureInputModel (),
308311 projectLabel : "my-project" ,
309- resp : & intake.IntakeResponse {Id : utils . Ptr ( "intake-id-123" ) },
312+ resp : & intake.IntakeResponse {Id : "intake-id-123" },
310313 },
311314 wantErr : false ,
312315 },
@@ -317,7 +320,7 @@ func TestOutputResult(t *testing.T) {
317320 model .Async = true
318321 }),
319322 projectLabel : "my-project" ,
320- resp : & intake.IntakeResponse {Id : utils . Ptr ( "intake-id-123" ) },
323+ resp : & intake.IntakeResponse {Id : "intake-id-123" },
321324 },
322325 wantErr : false ,
323326 },
@@ -327,7 +330,7 @@ func TestOutputResult(t *testing.T) {
327330 model : fixtureInputModel (func (model * inputModel ) {
328331 model .OutputFormat = print .JSONOutputFormat
329332 }),
330- resp : & intake.IntakeResponse {Id : utils . Ptr ( "intake-id-123" ) },
333+ resp : & intake.IntakeResponse {Id : "intake-id-123" },
331334 },
332335 wantErr : false ,
333336 },
0 commit comments