faas/gateway/plugin/external_test.go
Templum 6cd6975fe5 Moved label extraction to dedicated function.
Further I created some unit test which should cover all relevant scenarios for the created function.

Signed-off-by: Simon Pelczer <templum.dev@gmail.com>
2018-04-11 19:30:43 -07:00

32 lines
720 B
Go

package plugin
import "testing"
const fallbackValue = 120
func TestLabelValueWasEmpty(t *testing.T) {
extractedValue := extractLabelValue("", fallbackValue)
if extractedValue != fallbackValue {
t.Log("Expected extractedValue to equal the fallbackValue")
t.Fail()
}
}
func TestLabelValueWasValid(t *testing.T) {
extractedValue := extractLabelValue("42", fallbackValue)
if extractedValue != 42 {
t.Log("Expected extractedValue to equal answer to life (42)")
t.Fail()
}
}
func TestLabelValueWasInValid(t *testing.T) {
extractedValue := extractLabelValue("InvalidValue", fallbackValue)
if extractedValue != fallbackValue {
t.Log("Expected extractedValue to equal the fallbackValue")
t.Fail()
}
}