@@ -19,6 +19,20 @@ type TestsSpecification struct {
1919 Tests []TestCase `yaml:"tests"`
2020}
2121
22+ func getTests () (* TestsSpecification , error ) {
23+ data , err := ioutil .ReadFile ("tests.yml" )
24+ if err != nil {
25+ return nil , err
26+ }
27+ var spec TestsSpecification
28+ err = yaml .Unmarshal ([]byte (data ), & spec )
29+ if err != nil {
30+ return nil , err
31+ }
32+
33+ return & spec , nil
34+ }
35+
2236func testFunc (t * testing.T , function string , expectedURL string , root string , args ... string ) {
2337 var actualURL string
2438 switch function {
@@ -56,16 +70,10 @@ func testFunc(t *testing.T, function string, expectedURL string, root string, ar
5670}
5771
5872func TestURLs (t * testing.T ) {
59- data , err := ioutil . ReadFile ( "tests.yml" )
73+ spec , err := getTests ( )
6074 if err != nil {
6175 t .Error (err )
6276 }
63- var spec TestsSpecification
64- err = yaml .Unmarshal ([]byte (data ), & spec )
65- if err != nil {
66- t .Error (err )
67- }
68-
6977 for _ , test := range spec .Tests {
7078 for _ , argSet := range test .ArgSets {
7179 for cluster , rootURLs := range spec .RootURLs {
@@ -77,6 +85,22 @@ func TestURLs(t *testing.T) {
7785 }
7886}
7987
88+ func TestNormalize (t * testing.T ) {
89+ spec , err := getTests ()
90+ if err != nil {
91+ t .Error (err )
92+ }
93+
94+ expected := spec .RootURLs ["new" ][0 ]
95+ for _ , rootURL := range spec .RootURLs ["new" ] {
96+ actual := NormalizeRootURL (rootURL )
97+ if expected != actual {
98+ t .Errorf ("%v NormalizeRootURL(%v) = `%v` but should be `%v`" , redCross (), rootURL , actual , expected )
99+ }
100+ t .Logf ("%v NormalizeRootURL(%v) = `%v`" , greenTick (), rootURL , actual )
101+ }
102+ }
103+
80104// quotedList returns a backtick-quoted list of the arguments passed in
81105func quotedList (url string , args []string ) string {
82106 all := append ([]string {url }, args ... )
0 commit comments