match_test.go 639 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package host

import (
	"testing"
)

func TestSemverMatching(t *testing.T) {
	m, err := MultistreamSemverMatcher("/testing/4.3.5")
	if err != nil {
		t.Fatal(err)
	}

	cases := map[string]bool{
		"/testing/4.3.0":   true,
		"/testing/4.3.7":   true,
		"/testing/4.3.5":   true,
		"/testing/4.2.7":   true,
		"/testing/4.0.0":   true,
		"/testing/5.0.0":   false,
		"/cars/dogs/4.3.5": false,
		"/foo/1.0.0":       false,
		"":                 false,
		"dogs":             false,
		"/foo":             false,
		"/foo/1.1.1.1":     false,
	}

	for p, ok := range cases {
		if m(p) != ok {
			t.Fatalf("expected %s to be %t", p, ok)
		}
	}
}