node-labeler/units_test.go
okozachenko 9f265beb2b Fix the logic to check compute node
and add unit test for it

Change-Id: Icb7691c1f520a357f214b8cae19a748c278b22c9
2020-07-23 17:51:01 +03:00

34 lines
839 B
Go

package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func assertCheckComputeSubstring(t *testing.T, label string, expected bool) {
res := CheckComputeSubstring(label)
assert.Equal(t, expected, res)
}
func TestCheckComputeSubstringWithkvmHostname(t *testing.T) {
hostname := string("kvm10.specterops.iad1.vexxhost.net")
expected := bool(true)
assertCheckComputeSubstring(t, hostname, expected)
}
func TestCheckComputeSubstringWithcomputeHostname(t *testing.T) {
hostname := string("compute.specterops.iad1.vexxhost.net")
expected := bool(true)
assertCheckComputeSubstring(t, hostname, expected)
}
func TestCheckComputeSubstringWithNoneComputeHostname(t *testing.T) {
hostname := string("ctl1.specterops.iad1.vexxhost.net")
expected := bool(false)
assertCheckComputeSubstring(t, hostname, expected)
}