test(driver/gcs): fix predictive dates

Signed-off-by: Julien Breux <julienbreux@google.com>
pull/10922/head
Julien Breux 3 years ago
parent 3aa516783d
commit 1d90df771e
No known key found for this signature in database
GPG Key ID: BA2EB0E039AE0AB3

@ -55,6 +55,8 @@ type GCS struct {
namespace string
now string
Log func(string, ...interface{})
}
@ -73,6 +75,8 @@ func NewGCS(bucket, pathPrefix, namespace string, logger func(string, ...interfa
pathPrefix: pathPrefix,
namespace: namespace,
now: time.Now().Format("2006-01-02 15:04:05"),
Log: logger,
}
@ -275,17 +279,16 @@ func (s *GCS) fullPathName(name, namespace string) string {
// metadata returns the metadata list from release
func (s *GCS) metadata(rls *rspb.Release, isCreation bool) map[string]string {
ts := strconv.FormatInt(time.Now().UTC().UnixNano(), 10)
md := map[string]string{
gcsReleaseNameMetadata: rls.Name,
gcsReleaseNamespaceMetadata: rls.Namespace,
gcsReleaseStatusMetadata: rls.Info.Status.String(),
gcsReleaseVersionMetadata: strconv.Itoa(rls.Version),
gcsReleaseOwnerColumn: "helm",
gcsReleaseModifiedAtMetadata: ts,
gcsReleaseModifiedAtMetadata: s.now,
}
if isCreation {
md[gcsReleaseCreatedAtMetadata] = ts
md[gcsReleaseCreatedAtMetadata] = s.now
}
return md
}

File diff suppressed because one or more lines are too long

@ -30,12 +30,12 @@ import (
"cloud.google.com/go/storage"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
rspb "helm.sh/helm/v3/pkg/release"
)
var (
rec = flag.Bool("record", false, "record RPCs")
gcsNow = "1987-16-01 09:10:11"
gcsRec = flag.Bool("record", false, "record RPCs")
gcsDriver *GCS
)
@ -72,7 +72,6 @@ func clearObjects() {
}
func TestGCSName(t *testing.T) {
// gcsDriver := newTestFixtureGCS("helm-releases", "default")
if gcsDriver.Name() != GCSDriverName {
t.Errorf("Expected name to be %s, got %s", GCSDriverName, gcsDriver.Name())
}
@ -286,7 +285,7 @@ func newTestFixtureGCS() func() {
var hc *http.Client
cleanup := func() {}
if *rec {
if *gcsRec {
now := time.Now().UTC()
if !httpreplay.Supported() {
panic("HTTP replay not supported")
@ -332,7 +331,10 @@ func newTestFixtureGCS() func() {
pathPrefix: prefix,
namespace: namespace,
now: gcsNow,
Log: func(a string, b ...interface{}) {},
}
return cleanup
}

Loading…
Cancel
Save