-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_test.go
100 lines (88 loc) · 2.7 KB
/
project_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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestLoadProject(t *testing.T) {
proj, err := LoadProject("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Hacknet\\Extensions\\IntroExtension")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, proj.Info.Title, "Intro Extension")
assert.Len(t, proj.ActionSets, 7)
assert.Len(t, proj.Nodes, 10)
assert.Len(t, proj.Missions, 29)
assert.Len(t, proj.Factions, 2)
}
/*func TestNewProject(t *testing.T) {
dest := path.Join(os.TempDir(), "Test_New_Extension")
extInfo := &hacknet.ExtensionInfo{
Title: "Test New Extension",
AllowSaves: true,
Language: hacknet.English,
StartingNodes: hacknet.CSVList{"myTestComp"},
StartingMission: "Missions/StartingMission.xml",
StartingActions: "NONE",
Description: "This is a test extension! I shouldn't still be here.",
StartsWithTutorial: false,
HasIntroStartup: true,
StartingTheme: "Hacknet_Blue",
IntroStartupSong: "Whiplash",
}
proj, err := NewProject(*extInfo, dest)
if err != nil {
t.Fatal(err)
}
assert.NotNil(t, proj.Info)
assert.Equal(t, "Test New Extension", proj.Info.Title)
// check the new directories exists
if _, err := os.Stat(dest); err != nil {
if os.IsNotExist(err) {
t.Fatal("did not create project directory correctly")
}
}
if _, err := os.Stat(path.Join(dest, "Actions")); err != nil {
if os.IsNotExist(err) {
t.Fatal("did not create project structure correctly [actions]")
}
}
if _, err := os.Stat(path.Join(dest, "Factions")); err != nil {
if os.IsNotExist(err) {
t.Fatal("did not create project structure correctly [factions]")
}
}
if _, err := os.Stat(path.Join(dest, "Missions")); err != nil {
if os.IsNotExist(err) {
t.Fatal("did not create project structure correctly [missions]")
}
}
if _, err := os.Stat(path.Join(dest, "Nodes")); err != nil {
if os.IsNotExist(err) {
t.Fatal("did not create project structure correctly [missions]")
}
}
if _, err := os.Stat(path.Join(dest, "Themes")); err != nil {
if os.IsNotExist(err) {
t.Fatal("did not create project structure correctly [themes]")
}
}
// check extension info exists
if _, err := os.Stat(path.Join(dest, "ExtensionInfo.xml")); err != nil {
if os.IsNotExist(err) {
t.Fatal("did not create extension info correctly")
}
}
// check we can't accidentally overwrite the project
_, err = NewProject(*extInfo, dest)
if err == nil || err.Error() != "project directory already exists" {
t.Fatal("we shouldn't be overriding projects")
}
}
func TestDeleteProject(t *testing.T) {
dest := path.Join(os.TempDir(), "Test_New_Extension")
err := DeleteProject(dest)
if err != nil {
t.Fatal(err)
}
}
*/