Path: blob/main/components/content-service/pkg/storage/gcloud_test.go
2501 views
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package storage56import (7"context"8"strings"9"testing"1011gcp_storage "cloud.google.com/go/storage"12"github.com/fsouza/fake-gcs-server/fakestorage"13"google.golang.org/api/option"1415"github.com/gitpod-io/gitpod/content-service/api/config"16"github.com/gitpod-io/gitpod/content-service/pkg/archive"17)1819func TestObjectAccessToNonExistentObj(t *testing.T) {20t.Skip()2122server := *fakestorage.NewServer([]fakestorage.Object{})23defer server.Stop()2425args := []option.ClientOption{26option.WithoutAuthentication(),27option.WithEndpoint(server.URL()),28option.WithHTTPClient(server.HTTPClient()),29}3031ctx, cancelFunc := context.WithCancel(context.Background())32defer cancelFunc()3334client, err := gcp_storage.NewClient(ctx, args...)35if err != nil {36t.Errorf("error creating GCS gcsClient: %v", err)37}3839storage := DirectGCPStorage{40WorkspaceName: "fake-workspace-name",41InstanceID: "fake-instance-id",42Stage: config.StageDevStaging,43client: client,44}4546storage.ObjectAccess = storage.defaultObjectAccess4748var mappings []archive.IDMapping49found, err := storage.Download(context.Background(), "/tmp", "foo", mappings)50if err != nil && !strings.Contains(err.Error(), "object doesn't exist") {51t.Errorf("%+v", err)52}53if found {54t.Errorf("gcloud storage reported object found despite it being non-existent")55}56}575859