status-go/metrics/node/metrics_test.go

43 lines
982 B
Go
Raw Permalink Normal View History

package node
import (
"testing"
2020-01-02 09:10:19 +00:00
"github.com/stretchr/testify/require"
prom "github.com/prometheus/client_golang/prometheus"
)
func TestParsingLabelsFromNodeName(t *testing.T) {
var labels prom.Labels
var err error
// mobile name
labels, err = labelsFromNodeName("StatusIM/v0.30.1-beta.2/android-arm/go1.12")
require.NoError(t, err)
require.Equal(t, labels,
prom.Labels{
"platform": "android-arm",
"type": "StatusIM",
"version": "v0.30.1-beta.2",
})
// desktop name
labels, err = labelsFromNodeName("Statusd/v0.29.0-beta.2/linux-amd64/go1.11")
require.NoError(t, err)
require.Equal(t, labels,
prom.Labels{
"platform": "linux-amd64",
"type": "Statusd",
"version": "v0.29.0-beta.2",
})
// missing version
labels, err = labelsFromNodeName("StatusIM/android-arm64/go1.11")
require.NoError(t, err)
require.Equal(t, labels,
prom.Labels{
"platform": "android-arm64",
"type": "StatusIM",
"version": "unknown",
})
}