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

mendersoftware / mender-artifact / 1279561887

06 May 2024 07:18AM UTC coverage: 73.657% (-3.8%) from 77.428%
1279561887

Pull #605

gitlab-ci

alfrunes
chore(make): Refactor `coverage` target and disable pkcs11 on non-linux

Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Pull Request #605: Allow using mender-artifact without `cgo`

4 of 6 new or added lines in 1 file covered. (66.67%)

271 existing lines in 13 files now uncovered.

5469 of 7425 relevant lines covered (73.66%)

77.7 hits per line

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

0.0
/utils/progress.go
1
// Copyright 2021 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
package utils
16

17
import (
18
        "io"
19

20
        "github.com/mendersoftware/progressbar"
21
)
22

23
type ProgressReader struct {
24
        bar *progressbar.Bar
25
        io.Reader
26
}
27

UNCOV
28
func NewProgressReader() *ProgressReader {
×
UNCOV
29
        return &ProgressReader{}
×
UNCOV
30
}
×
31

UNCOV
32
func (p *ProgressReader) Wrap(r io.Reader, size int64) io.Reader {
×
UNCOV
33
        bar := progressbar.New(size)
×
UNCOV
34
        bar.Size = size
×
UNCOV
35
        return &ProgressReader{
×
UNCOV
36
                Reader: r,
×
UNCOV
37
                bar:    bar,
×
UNCOV
38
        }
×
UNCOV
39
}
×
40

UNCOV
41
func (p *ProgressReader) Read(b []byte) (int, error) {
×
UNCOV
42
        n, err := p.Reader.Read(b)
×
UNCOV
43
        p.bar.Tick(int64(n))
×
UNCOV
44
        return n, err
×
UNCOV
45
}
×
46

47
type ProgressWriter struct {
48
        bar    *progressbar.Bar
49
        Writer io.WriteCloser
50
}
51

UNCOV
52
func NewProgressWriter() *ProgressWriter {
×
UNCOV
53
        return &ProgressWriter{}
×
UNCOV
54
}
×
55

UNCOV
56
func (p *ProgressWriter) Wrap(w io.WriteCloser) io.Writer {
×
UNCOV
57
        p.Writer = w
×
UNCOV
58
        return p
×
UNCOV
59
}
×
60

UNCOV
61
func (p *ProgressWriter) Reset(size int64, filename string, payloadNumber int) {
×
UNCOV
62
        p.bar = progressbar.New(size)
×
UNCOV
63
        p.bar.Size = size
×
UNCOV
64
}
×
65

UNCOV
66
func (p *ProgressWriter) Finish() {
×
UNCOV
67
        if p.bar != nil {
×
UNCOV
68
                p.bar.Finish()
×
UNCOV
69
        }
×
70
}
71

UNCOV
72
func (p *ProgressWriter) Write(b []byte) (int, error) {
×
UNCOV
73
        n, err := p.Writer.Write(b)
×
UNCOV
74
        p.bar.Tick(int64(n))
×
UNCOV
75
        return n, err
×
UNCOV
76
}
×
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