github.com/tinkler/moonmist@v0.0.4/internal/parser/parser_test.go (about) 1 package parser 2 3 import ( 4 "os" 5 "testing" 6 ) 7 8 func TestParsePackage(t *testing.T) { 9 if err := os.Chdir("../.."); err != nil { 10 t.Fatal(err) 11 } 12 root, _ := os.Getwd() 13 pkg, err := ParsePackage("pkg/model/user", GetModulePath(root)) 14 if err != nil { 15 t.Fatal(err) 16 } 17 t.Log(pkg) 18 } 19 20 func TestParsePackageWithStream(t *testing.T) { 21 if err := os.Chdir("../.."); err != nil { 22 t.Fatal(err) 23 } 24 root, _ := os.Getwd() 25 pkg, err := ParsePackage("pkg/model/page", GetModulePath(root)) 26 if err != nil { 27 t.Fatal(err) 28 } 29 t.Log(pkg) 30 } 31 32 func TestParseMapType(t *testing.T) { 33 mapStr := "map[string]Chapter" 34 match := mapTypeRe.FindStringSubmatch(mapStr) 35 if match[1] != "string" { 36 t.Fail() 37 } 38 if match[2] != "Chapter" { 39 t.Fail() 40 } 41 }