• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cinode / go / 3736023969

19 Dec 2022 11:26PM UTC coverage: 79.498%. First build
3736023969

push

github

Bartek
Basic test for the static_datastore binary

919 of 1156 relevant lines covered (79.5%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.11
/internal/blobtypes/generation/blob_type_static.go
1
package generation
2

3
import (
4
        "crypto/sha256"
5
        "hash"
6
        "io"
7
)
8

9
type staticBlobHandler struct {
10
        newHasher func() hash.Hash
11
}
12

13
// PrepareNewBlob generates the blob name from blob's content hash.
14
// There's no WriterInfo generated since anybody can create any static blob.
15
func (h staticBlobHandler) PrepareNewBlob(data io.Reader) ([]byte, WriterInfo, error) {
1✔
16
        hasher := h.newHasher()
1✔
17

1✔
18
        _, err := io.Copy(hasher, data)
1✔
19
        if err != nil {
1✔
20
                return nil, nil, err
×
21
        }
×
22

23
        return hasher.Sum(nil), nil, nil
1✔
24
}
25

26
func (h staticBlobHandler) SendUpdate(hash []byte, wi WriterInfo, data io.Reader, out io.Writer) error {
×
27
        // TODO: Shouldn't we validate the data?
×
28
        _, err := io.Copy(out, data)
×
29
        return err
×
30
}
×
31

32
func newStaticBlobHandlerSha256() Handler {
1✔
33
        return staticBlobHandler{
1✔
34
                newHasher: sha256.New,
1✔
35
        }
1✔
36
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc