Browse code

Display only the name of the requirement…

… relative to the integration-cli package

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2016/12/27 03:20:27
Showing 1 changed files
... ...
@@ -2,8 +2,10 @@ package requirement
2 2
 
3 3
 import (
4 4
 	"fmt"
5
+	"path"
5 6
 	"reflect"
6 7
 	"runtime"
8
+	"strings"
7 9
 )
8 10
 
9 11
 type skipT interface {
... ...
@@ -20,7 +22,12 @@ func Is(s skipT, requirements ...Test) {
20 20
 		isValid := r()
21 21
 		if !isValid {
22 22
 			requirementFunc := runtime.FuncForPC(reflect.ValueOf(r).Pointer()).Name()
23
-			s.Skip(fmt.Sprintf("unmatched requirement %s", requirementFunc))
23
+			s.Skip(fmt.Sprintf("unmatched requirement %s", extractRequirement(requirementFunc)))
24 24
 		}
25 25
 	}
26 26
 }
27
+
28
+func extractRequirement(requirementFunc string) string {
29
+	requirement := path.Base(requirementFunc)
30
+	return strings.SplitN(requirement, ".", 2)[1]
31
+}