Skip to content

Commit

Permalink
Attempt to resolve peimanja#139
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperPerschke committed Apr 20, 2024
1 parent b9c0dbb commit 7c7e384
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions collector/converter_internals.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

var mulConvDriver = map[string]float64{
``: 1,
`%`: 0.01,
`bytes`: 1,
`KB`: math.Exp2(10),
Expand Down
20 changes: 20 additions & 0 deletions collector/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ func TestConvNum(t *testing.T) {
input: `888.88 GB`,
want: 954427632517.119995,
},
{
// Covers https://github.com/peimanja/artifactory_exporter/issues/139
input: `1`,
want: 1.0,
},
{
// Covers https://github.com/peimanja/artifactory_exporter/issues/139
input: `44`,
want: 44.0,
},
{
// Covers https://github.com/peimanja/artifactory_exporter/issues/139
input: `100 %`,
want: 1.0,
},
}
for _, tc := range tests {
got, err := fakeExporter.convArtiToPromNumber(tc.input)
Expand Down Expand Up @@ -94,6 +109,11 @@ func TestConvFileStoreData(t *testing.T) {
input: `494.94 GB (99.04%)`,
want: []float64{531437778370.559998, 0.9904},
},
{
// Just to check https://github.com/peimanja/artifactory_exporter/issues/139
input: `1.0 GB (1.0%)`,
want: []float64{1073741824.000000, 0.0100},
},
}
for _, tc := range tests {
gotSize, gotPercent, err := fakeExporter.convArtiToPromFileStoreData(tc.input)
Expand Down

0 comments on commit 7c7e384

Please sign in to comment.