Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-diwakar committed Aug 21, 2024
1 parent 1c8df23 commit 67b2c9e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions storage/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ type BucketAttrs struct {
// This field is read-only.
Created time.Time

// Time at which the bucket was last modified.
// Updated is the time at which the bucket was last modified.
// This field is read-only.
Updated time.Time

Expand Down Expand Up @@ -928,7 +928,6 @@ func (b *BucketAttrs) toRawBucket() *raw.Bucket {
Name: b.Name,
Location: b.Location,
StorageClass: b.StorageClass,
Updated: b.Updated.Format(time.RFC3339),
Acl: toRawBucketACL(b.ACL),
DefaultObjectAcl: toRawObjectACL(b.DefaultObjectACL),
Versioning: v,
Expand Down Expand Up @@ -991,7 +990,6 @@ func (b *BucketAttrs) toProtoBucket() *storagepb.Bucket {
Name: b.Name,
Location: b.Location,
StorageClass: b.StorageClass,
UpdateTime: toProtoTimestamp(b.Updated),
Acl: toProtoBucketACL(b.ACL),
DefaultObjectAcl: toProtoObjectACL(b.DefaultObjectACL),
Versioning: v,
Expand Down
4 changes: 2 additions & 2 deletions storage/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
// should be ignored:
MetaGeneration: 39,
Created: time.Now(),
Updated: time.Now(),
Labels: map[string]string{"label": "value"},
CORS: []CORS{
{
Expand Down Expand Up @@ -158,7 +157,6 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
},
PublicAccessPrevention: "enforced",
},
Updated: time.Now().Format("2006-01-02T15:04:05Z07:00"),
Versioning: nil, // ignore VersioningEnabled if false
Rpo: rpoAsyncTurbo,
Labels: map[string]string{"label": "value"},
Expand Down Expand Up @@ -607,6 +605,7 @@ func TestNewBucket(t *testing.T) {
Metageneration: 3,
StorageClass: "sc",
TimeCreated: "2017-10-23T04:05:06Z",
Updated: "2024-08-21T17:24:53Z",
Versioning: &raw.BucketVersioning{Enabled: true},
Labels: labels,
Billing: &raw.BucketBilling{RequesterPays: true},
Expand Down Expand Up @@ -678,6 +677,7 @@ func TestNewBucket(t *testing.T) {
MetaGeneration: 3,
StorageClass: "sc",
Created: time.Date(2017, 10, 23, 4, 5, 6, 0, time.UTC),
Updated: time.Date(2024, 8, 21, 17, 24, 53, 0, time.UTC),
VersioningEnabled: true,
Labels: labels,
Etag: "Zkyw9ACJZUvcYmlFaKGChzhmtnE/dt1zHSfweiWpwzdGsqXwuJZqiD0",
Expand Down
10 changes: 5 additions & 5 deletions storage/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func TestIntegration_BucketUpdate(t *testing.T) {
t.Fatalf("add labels: got %v, want %v", attrs.Labels, wantLabels)
}
if !attrs.Created.Before(attrs.Updated) {
t.Fatal("attrs.Updated should be newer than attrs.Created")
t.Errorf("got attrs.Updated %v before attrs.Created %v, want Attrs.Updated to be after", attrs.Updated, attrs.Created)
}

// Turn off versioning again; add and remove some more labels.
Expand All @@ -611,7 +611,7 @@ func TestIntegration_BucketUpdate(t *testing.T) {
t.Fatalf("got %v, want %v", attrs.Labels, wantLabels)
}
if !attrs.Created.Before(attrs.Updated) {
t.Fatal("attrs.Updated should be newer than attrs.Created")
t.Errorf("got attrs.Updated %v before attrs.Created %v, want Attrs.Updated to be after", attrs.Updated, attrs.Created)
}

// Configure a lifecycle
Expand All @@ -633,7 +633,7 @@ func TestIntegration_BucketUpdate(t *testing.T) {
t.Fatalf("got %v, want %v", attrs.Lifecycle, wantLifecycle)
}
if !attrs.Created.Before(attrs.Updated) {
t.Fatal("attrs.Updated should be newer than attrs.Created")
t.Errorf("got attrs.Updated %v before attrs.Created %v, want Attrs.Updated to be after", attrs.Updated, attrs.Created)
}
// Check that StorageClass has "STANDARD" value for unset field by default
// before passing new value.
Expand All @@ -648,7 +648,7 @@ func TestIntegration_BucketUpdate(t *testing.T) {
t.Fatalf("got %v, want %v", attrs.StorageClass, wantStorageClass)
}
if !attrs.Created.Before(attrs.Updated) {
t.Fatal("attrs.Updated should be newer than attrs.Created")
t.Errorf("got attrs.Updated %v before attrs.Created %v, want Attrs.Updated to be after", attrs.Updated, attrs.Created)
}

// Empty update should succeed without changing the bucket.
Expand All @@ -660,7 +660,7 @@ func TestIntegration_BucketUpdate(t *testing.T) {
t.Fatalf("empty update: got %v, want %v", gotAttrs, attrs)
}
if !attrs.Created.Before(attrs.Updated) {
t.Fatal("attrs.Updated should be newer than attrs.Created")
t.Errorf("got attrs.Updated %v before attrs.Created %v, want Attrs.Updated to be after", attrs.Updated, attrs.Created)
}
})
}
Expand Down

0 comments on commit 67b2c9e

Please sign in to comment.