Feat project create with dir name add test (#2576)
* fix issue:#2358 Support for creating a project with specifying the name for its place dir * add test and fixed path of dir * fixed bug:nomod param not working as expect * fix test * fix go1.16 unit test Co-authored-by: czyt <czyt@w.cn>pull/2598/head
parent
6f78ccacd9
commit
852a77faa6
@ -0,0 +1,29 @@ |
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package project |
||||
|
||||
import ( |
||||
"testing" |
||||
) |
||||
|
||||
func Test_getProjectPlaceDir(t *testing.T) { |
||||
type args struct { |
||||
projectName string |
||||
fallbackPlaceDir string |
||||
} |
||||
tests := []struct { |
||||
name string |
||||
args args |
||||
want string |
||||
}{ |
||||
{"absLinux", args{projectName: "/home/kratos/awesome/go/demo", fallbackPlaceDir: ""}, "/home/kratos/awesome/go"}, |
||||
} |
||||
for _, tt := range tests { |
||||
t.Run(tt.name, func(t *testing.T) { |
||||
if got := getProjectPlaceDir(tt.args.projectName, tt.args.fallbackPlaceDir); got != tt.want { |
||||
t.Errorf("getProjectPlaceDir() = %v, want %v", got, tt.want) |
||||
} |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,30 @@ |
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package project |
||||
|
||||
import ( |
||||
"testing" |
||||
) |
||||
|
||||
func Test_getProjectPlaceDir(t *testing.T) { |
||||
type args struct { |
||||
projectName string |
||||
fallbackPlaceDir string |
||||
} |
||||
tests := []struct { |
||||
name string |
||||
args args |
||||
want string |
||||
}{ |
||||
{"absWindows", args{projectName: "c:\\kratos\\awesome\\go\\demo", fallbackPlaceDir: ""}, "c:\\kratos\\awesome\\go"}, |
||||
//{"relativeWindows", args{projectName: "/home/kratos/awesome/go/demo", fallbackPlaceDir: ""}, "/home/kratos/awesome/go"},
|
||||
} |
||||
for _, tt := range tests { |
||||
t.Run(tt.name, func(t *testing.T) { |
||||
if got := getProjectPlaceDir(tt.args.projectName, tt.args.fallbackPlaceDir); got != tt.want { |
||||
t.Errorf("getProjectPlaceDir() = %v, want %v", got, tt.want) |
||||
} |
||||
}) |
||||
} |
||||
} |
Loading…
Reference in new issue