MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / testBucket

Function testBucket

pkg/blob/bucket_test.go:38–63  ·  view source on GitHub ↗
(t *testing.T, conf config.BlobConfig)

Source from the content-addressed store, hash-verified

36}
37
38func testBucket(t *testing.T, conf config.BlobConfig) {
39 a := assertions.New(t)
40 ctx := test.Context()
41
42 bucket, err := conf.Bucket(ctx, bucketName(), test.HTTPClientProvider)
43 if !a.So(err, should.BeNil) {
44 t.Errorf("Failed to create bucket: %v", err)
45 return
46 }
47
48 now := time.Now().Format(time.RFC3339)
49
50 contents := []byte(now)
51 err = bucket.WriteAll(ctx, "path/to/file", contents, WriterOptions("text/plain", "key", "value"))
52 if !a.So(err, should.BeNil) {
53 t.Errorf("Failed to write contents: %v", err)
54 return
55 }
56
57 res, err := bucket.ReadAll(ctx, "path/to/file")
58 if !a.So(err, should.BeNil) {
59 t.Errorf("Failed to read contents: %v", err)
60 return
61 }
62 a.So(res, should.Resemble, contents)
63}
64
65func TestLocal(t *testing.T) {
66 a := assertions.New(t)

Callers 3

TestLocalFunction · 0.85
TestAWSFunction · 0.85
TestGCPFunction · 0.85

Calls 8

ContextFunction · 0.92
bucketNameFunction · 0.85
WriterOptionsFunction · 0.85
BucketMethod · 0.80
NewMethod · 0.65
ErrorfMethod · 0.65
FormatMethod · 0.65
NowMethod · 0.65

Tested by

no test coverage detected