-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit_test.go
69 lines (58 loc) · 1.37 KB
/
init_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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"fmt"
"github.com/DATA-DOG/godog"
"llama/cmd"
"os"
"path/filepath"
"reflect"
)
var projectName []string
func iNeedToCreateMy_project(name string) error {
projectName = []string{name}
return nil
}
func iInvokeLlamaInitMy_project() error {
cmd.CreateProject(projectName)
return nil
}
func aDirectoryWithAllNeededFilesWillBeCreated() error {
var files []string
expected := []string{
"./my_project",
"my_project/deployment",
"my_project/src",
"my_project/src/code.go",
}
err := filepath.Walk("./my_project",
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
files = append(files, path)
return nil
})
if err != nil {
fmt.Println(err)
}
fmt.Println(files, expected)
if !reflect.DeepEqual(files, expected) {
return fmt.Errorf("files should equal %v but equals %v", expected, files)
}
return nil
}
func FeatureContext(s *godog.Suite) {
s.Step(`^I need to create (\w+)$`, iNeedToCreateMy_project)
s.Step(`^I invoke llama init (\w+)$`, iInvokeLlamaInitMy_project)
s.Step(`^a directory with all needed files will be created$`, aDirectoryWithAllNeededFilesWillBeCreated)
s.AfterScenario(func(interface{}, error) {
current_path, err := os.Getwd()
if err != nil {
fmt.Println(err)
}
err = os.RemoveAll(current_path + "/" + projectName[0])
if err != nil {
fmt.Println(err)
}
})
}