tangled
alpha
login
or
join now
cosmeak.dev
/
weave
0
fork
atom
A Minecraft datapack generator written in go.
0
fork
atom
overview
issues
pulls
pipelines
feat(function): add basic testing
cosmeak.dev
2 months ago
8eecfa90
2656d3bb
+44
1 changed file
expand all
collapse all
unified
split
function
function_test.go
+44
function/function_test.go
···
1
1
+
package function_test
2
2
+
3
3
+
import (
4
4
+
"os"
5
5
+
"path/filepath"
6
6
+
"strings"
7
7
+
"testing"
8
8
+
9
9
+
"tangled.org/cosmeak.tngl.sh/weave"
10
10
+
"tangled.org/cosmeak.tngl.sh/weave/function"
11
11
+
)
12
12
+
13
13
+
func TestFunctionGeneration(t *testing.T) {
14
14
+
out := t.TempDir()
15
15
+
16
16
+
pack := weave.
17
17
+
MkDatapack("test", "Test pack", 88, 88, []string{"vanilla"}).
18
18
+
AddFeature(function.MkFunction(
19
19
+
"set_day",
20
20
+
"time set day",
21
21
+
"say Daytime!",
22
22
+
))
23
23
+
24
24
+
if err := pack.Generate(out); err != nil {
25
25
+
t.Fatalf("generate failed: %v", err)
26
26
+
}
27
27
+
28
28
+
path := filepath.Join(
29
29
+
out,
30
30
+
"test", "data", "test", "function", "set_day.mcfunction",
31
31
+
)
32
32
+
33
33
+
data, err := os.ReadFile(path)
34
34
+
if err != nil {
35
35
+
t.Fatalf("expected file not found: %v", err)
36
36
+
}
37
37
+
38
38
+
got := strings.TrimSpace(string(data))
39
39
+
want := "time set day\nsay Daytime!"
40
40
+
41
41
+
if got != want {
42
42
+
t.Errorf("unexpected file content:\n%s", got)
43
43
+
}
44
44
+
}