Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/content-service/pkg/storage/gcloud_test.go
2501 views
1
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package storage
6
7
import (
8
"context"
9
"strings"
10
"testing"
11
12
gcp_storage "cloud.google.com/go/storage"
13
"github.com/fsouza/fake-gcs-server/fakestorage"
14
"google.golang.org/api/option"
15
16
"github.com/gitpod-io/gitpod/content-service/api/config"
17
"github.com/gitpod-io/gitpod/content-service/pkg/archive"
18
)
19
20
func TestObjectAccessToNonExistentObj(t *testing.T) {
21
t.Skip()
22
23
server := *fakestorage.NewServer([]fakestorage.Object{})
24
defer server.Stop()
25
26
args := []option.ClientOption{
27
option.WithoutAuthentication(),
28
option.WithEndpoint(server.URL()),
29
option.WithHTTPClient(server.HTTPClient()),
30
}
31
32
ctx, cancelFunc := context.WithCancel(context.Background())
33
defer cancelFunc()
34
35
client, err := gcp_storage.NewClient(ctx, args...)
36
if err != nil {
37
t.Errorf("error creating GCS gcsClient: %v", err)
38
}
39
40
storage := DirectGCPStorage{
41
WorkspaceName: "fake-workspace-name",
42
InstanceID: "fake-instance-id",
43
Stage: config.StageDevStaging,
44
client: client,
45
}
46
47
storage.ObjectAccess = storage.defaultObjectAccess
48
49
var mappings []archive.IDMapping
50
found, err := storage.Download(context.Background(), "/tmp", "foo", mappings)
51
if err != nil && !strings.Contains(err.Error(), "object doesn't exist") {
52
t.Errorf("%+v", err)
53
}
54
if found {
55
t.Errorf("gcloud storage reported object found despite it being non-existent")
56
}
57
}
58
59