-
Notifications
You must be signed in to change notification settings - Fork 2
/
node_test.go
78 lines (66 loc) · 1.71 KB
/
node_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
70
71
72
73
74
75
76
77
78
package main
import (
"bufio"
"io"
"os"
"os/exec"
"github.com/AlexsJones/kepler/commands/node"
"github.com/DATA-DOG/godog"
)
const (
p = `{
"name": "api",
"version": "3.1.15",
"description": "Common config",
"main": "index.js",
"scripts": {
"test": "mocha test/index.js"
},
"author": "Test <[email protected]>",
"private": true,
"license": "ISC",
"dependencies": {
"confidence": "^1.4.2",
"debug": "^2.3.3",
"joi": "^10.6.0",
"lodash": "^4.17.4",
"shortid": "^2.2.8",
"swig": "^1.4.2",
"uuid": "^2.0.2"
}
}`
)
func iHaveAGeneratedTestSubmoduleWithNodePackagejson() error {
os.Mkdir("test-submodule-repo", 0755)
exec.Command("bash", "-c", "cd test-submodule-repo && git init").CombinedOutput()
_, err := os.Stat("test-submodule-repo")
if err != nil {
return err
}
exec.Command("bash", "-c", "git submodule add ./test-submodule-repo").CombinedOutput()
f, err := os.Create("./test-submodule-repo/package.json")
if err != nil {
return err
}
w := bufio.NewWriter(f)
io.WriteString(w, p)
w.Flush()
return nil
}
func iAttemptToUpdatePackageContents() error {
_, err := node.LocalNodeModules()
if err != nil {
return err
}
return nil
}
func iAmAbleToValidateTheChangesWithinThePackageHaveBeenMade() error {
os.RemoveAll("test-submodule-repo")
os.Remove(".gitmodules")
return nil
}
func FeatureContext(s *godog.Suite) {
s.Step(`^I have a generated test submodule with node package\.json$`, iHaveAGeneratedTestSubmoduleWithNodePackagejson)
s.Step(`^I attempt to update package contents$`, iAttemptToUpdatePackageContents)
s.Step(`^I am able to validate the changes within the package have been made$`, iAmAbleToValidateTheChangesWithinThePackageHaveBeenMade)
}