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

trento-project / agent / 12876938621

20 Jan 2025 11:05PM UTC coverage: 71.655% (-0.2%) from 71.827%
12876938621

Pull #378

github

balanza
accept feedback
Pull Request #378: Test command termination error

2 of 4 new or added lines in 1 file covered. (50.0%)

22 existing lines in 1 file now uncovered.

4065 of 5673 relevant lines covered (71.66%)

20.21 hits per line

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

0.0
/pkg/utils/utils.go
1
package utils
2

3
import (
4
        "regexp"
5
        "strings"
6
)
7

8
// FindMatches finds regular expression matches in a key/value based
9
// text (ini files, for example), and returns a map with them.
10
// If the matched key has spaces, they will be replaced with underscores
11
// If the same keys is found multiple times, the entry of the map will
12
// have a list as value with all of the matched values
13
// The pattern must have 2 groups. For example: `(.+)=(.*)`
UNCOV
14
func FindMatches(pattern string, text []byte) map[string]interface{} {
×
UNCOV
15
        configMap := make(map[string]interface{})
×
UNCOV
16

×
UNCOV
17
        r := regexp.MustCompile(pattern)
×
UNCOV
18
        values := r.FindAllStringSubmatch(string(text), -1)
×
UNCOV
19
        for _, match := range values {
×
UNCOV
20
                key := strings.Replace(match[1], " ", "_", -1) //nolint
×
UNCOV
21
                if _, ok := configMap[key]; ok {
×
UNCOV
22
                        switch configMap[key].(type) { //nolint
×
UNCOV
23
                        case string:
×
UNCOV
24
                                configMap[key] = []interface{}{configMap[key]}
×
25
                        }
UNCOV
26
                        configMap[key] = append(configMap[key].([]interface{}), match[2]) //nolint
×
UNCOV
27
                } else {
×
UNCOV
28
                        configMap[key] = match[2]
×
UNCOV
29
                }
×
30
        }
UNCOV
31
        return configMap
×
32
}
33

UNCOV
34
func Contains[T comparable](s []T, e T) bool {
×
UNCOV
35
        for _, v := range s {
×
UNCOV
36
                if v == e {
×
UNCOV
37
                        return true
×
UNCOV
38
                }
×
39
        }
UNCOV
40
        return false
×
41
}
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

© 2026 Coveralls, Inc