forked from jenkins-x/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
34 lines (30 loc) · 940 Bytes
/
util_test.go
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
34
// Copyright 2017 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package scm
import "testing"
func TestSplit(t *testing.T) {
tests := []struct {
value, owner, name string
}{
{"octocat/hello-world", "octocat", "hello-world"},
{"octocat/hello/world", "octocat", "hello/world"},
{"hello-world", "", "hello-world"},
{value: ""}, // empty value returns nothing
}
for _, test := range tests {
owner, name := Split(test.value)
if got, want := owner, test.owner; got != want {
t.Errorf("Got repository owner %s, want %s", got, want)
}
if got, want := name, test.name; got != want {
t.Errorf("Got repository name %s, want %s", got, want)
}
}
}
func TestJoin(t *testing.T) {
got, want := Join("octocat", "hello-world"), "octocat/hello-world"
if got != want {
t.Errorf("Got repository name %s, want %s", got, want)
}
}