Skip to content

Commit

Permalink
Merge pull request #3065 from xiaoweim/mockgcp_bigquerydataset
Browse files Browse the repository at this point in the history
tests:fix mockgcp for bigquery to mimic real GCP behavoir
  • Loading branch information
xiaoweim authored Nov 4, 2024
2 parents c59441c + b65ca59 commit f485d48
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 6 deletions.
6 changes: 6 additions & 0 deletions mockgcp/mockbigquery/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"github.com/golang/protobuf/ptypes/empty"
)

var defaultMaxTimeTravelHours = int64(168)

type datasetsServer struct {
*MockService
pb.UnimplementedDatasetsServerServer
Expand All @@ -52,6 +54,10 @@ func (s *datasetsServer) GetDataset(ctx context.Context, req *pb.GetDatasetReque
return nil, err
}

if obj.MaxTimeTravelHours == nil {
obj.MaxTimeTravelHours = &defaultMaxTimeTravelHours
}

return obj, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
specialGroup: projectWriters
friendlyName: bigquerydataset-sample-updated
location: US
maxTimeTravelHours: "168"
projectRef:
external: ${projectId}
resourceID: bigquerydatasetsample${uniqueId}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -183,7 +184,8 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t
"cnrm-test": "true",
"managed-by-cnrm": "true"
},
"location": "US"
"location": "US",
"maxTimeTravelHours": "168"
}

200 OK
Expand Down Expand Up @@ -231,6 +233,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -286,6 +289,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
description: BigQuery Dataset With Access Block v2
friendlyName: bigquerydataset-accessblock
location: US
maxTimeTravelHours: "168"
projectRef:
external: ${projectId}
resourceID: bigquerydataset${uniqueId}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -181,7 +182,8 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t
"cnrm-test": "true",
"managed-by-cnrm": "true"
},
"location": "US"
"location": "US",
"maxTimeTravelHours": "168"
}

200 OK
Expand Down Expand Up @@ -227,6 +229,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -280,6 +283,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -881,6 +882,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "us-central1",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -407,6 +408,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "us-central1",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "us-central1",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -542,6 +543,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "us-central1",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -1413,6 +1414,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -1607,6 +1608,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
specialGroup: projectWriters
friendlyName: bigquerydataset-sample-updated
location: US
maxTimeTravelHours: "168"
projectRef:
external: ${projectId}
resourceID: bigquerydatasetsample${uniqueId}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -183,7 +184,8 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t
"cnrm-test": "true",
"managed-by-cnrm": "true"
},
"location": "US"
"location": "US",
"maxTimeTravelHours": "168"
}

200 OK
Expand Down Expand Up @@ -231,6 +233,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -286,6 +289,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
specialGroup: projectWriters
friendlyName: bigquerydataset-sample-updated
location: US
maxTimeTravelHours: "168"
projectRef:
external: ${projectId}
resourceID: bigquerydatasetsample${uniqueId}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -183,7 +184,8 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t
"cnrm-test": "true",
"managed-by-cnrm": "true"
},
"location": "US"
"location": "US",
"maxTimeTravelHours": "168"
}

200 OK
Expand Down Expand Up @@ -231,6 +233,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -286,6 +289,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset_resourceid_${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -445,6 +446,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset_resourceid_${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
specialGroup: projectWriters
friendlyName: bigquerydataset-sample-updated
location: US
maxTimeTravelHours: "168"
projectRef:
external: ${projectId}
resourceID: bigquerydataset_${uniqueId}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset_${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -183,7 +184,8 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t
"cnrm-test": "true",
"managed-by-cnrm": "true"
},
"location": "US"
"location": "US",
"maxTimeTravelHours": "168"
}

200 OK
Expand Down Expand Up @@ -231,6 +233,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset_${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -286,6 +289,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset_${uniqueId}",
"type": "DEFAULT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
specialGroup: projectWriters
friendlyName: bigquerydataset-sample-updated
location: US
maxTimeTravelHours: "168"
projectRef:
external: ${projectId}
resourceID: bigquerydatasetsample${uniqueId}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -183,7 +184,8 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t
"cnrm-test": "true",
"managed-by-cnrm": "true"
},
"location": "US"
"location": "US",
"maxTimeTravelHours": "168"
}

200 OK
Expand Down Expand Up @@ -231,6 +233,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down Expand Up @@ -286,6 +289,7 @@ X-Xss-Protection: 0
},
"lastModifiedTime": "123456789",
"location": "US",
"maxTimeTravelHours": "168",
"selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydatasetsample${uniqueId}",
"type": "DEFAULT"
}
Expand Down

0 comments on commit f485d48

Please sign in to comment.