-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_test.go
More file actions
40 lines (34 loc) · 797 Bytes
/
utils_test.go
File metadata and controls
40 lines (34 loc) · 797 Bytes
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
35
36
37
38
39
40
package yaber
import (
"os"
"testing"
)
func failOnError(t *testing.T, e error) {
if e != nil {
t.Errorf("Unexpected error: %v\n", e)
}
}
func expectPkgName(t *testing.T, expected, path string) error {
pkg, e := getPackageName(path)
if e != nil {
return e
}
if pkg != expected {
t.Errorf("Bad package name, wanted: %s, got: %s\n", expected, pkg)
}
return nil
}
func TestPackageNameNotGo(t *testing.T) {
e := expectPkgName(t, "templates", "./example/templates")
failOnError(t, e)
}
func TestPackageNameIsGo(t *testing.T) {
e := expectPkgName(t, "main", "./example")
failOnError(t, e)
}
func TestPackageNameBadPath(t *testing.T) {
e := expectPkgName(t, "", "./example/notadir")
if _, ok := e.(*os.PathError); !ok {
t.Errorf("Expected os.PathError, got: %#v\n", e)
}
}