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

Function TestBucket

pkg/fetch/bucket_test.go:27–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestBucket(t *testing.T) {
28 a := assertions.New(t)
29 ctx := test.Context()
30
31 conf := config.BlobConfig{Provider: "local"}
32 conf.Local.Directory = t.TempDir()
33
34 filename := "file"
35 content := []byte("Hello world")
36
37 bucket, err := conf.Bucket(ctx, "bucket", test.HTTPClientProvider)
38 a.So(err, should.BeNil)
39
40 err = bucket.WriteAll(ctx, filename, content, nil)
41 a.So(err, should.BeNil)
42
43 fetcher := FromBucket(ctx, bucket, "")
44
45 // Reading working file
46 {
47 fileContent, err := fetcher.File(filename)
48 a.So(err, should.BeNil)
49 a.So(string(fileContent), should.Equal, string(content))
50 }
51
52 // Reading non-working file
53 {
54 _, err = fetcher.File("non-existing file")
55 a.So(err, should.NotBeNil)
56 }
57}

Callers

nothing calls this directly

Calls 5

BucketMethod · 0.95
ContextFunction · 0.92
FromBucketFunction · 0.85
NewMethod · 0.65
FileMethod · 0.65

Tested by

no test coverage detected