-
Notifications
You must be signed in to change notification settings - Fork 0
/
toml_test.go
84 lines (66 loc) · 1.57 KB
/
toml_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
package main
import (
"testing"
)
func TestParseConfig(t *testing.T) {
t.Parallel()
expected := "netlify.toml"
config, err := parseConfigFile("fixtures/config.toml")
if err != nil {
t.Fatalf("Error in parsing")
}
for _, repos := range config.TargetRepository {
if repos.TargetFile != expected {
t.Errorf("Expected %v and real %v)", expected, repos.TargetFile)
}
}
}
func TestParseNetlifyConfig(t *testing.T) {
t.Parallel()
expected := "0.83.1"
config, err := parseNetlifyConfFile("fixtures/netlify.toml")
if err != nil {
t.Fatalf("Error in parsing")
}
real := config.Build.BuildEnv.HugoVersion
if real != expected {
t.Errorf("Expected %v and real %v)", expected, real)
}
}
func TestParseNetlifyConfigDirect(t *testing.T) {
t.Parallel()
expected := "0.83.1"
content := `
[build]
command = "hugo --gc --minify -b $URL"
[build.environment]
HUGO_VERSION = "0.83.1"
HUGO_ENABLEGITINFO = "true"
`
config, err := parseNetlifyConf(content)
if err != nil {
t.Fatalf("Error in parsing")
}
real := config.Build.BuildEnv.HugoVersion
if real != expected {
t.Errorf("Expected %v and real %v)", expected, real)
}
}
func TestReplaceVersion(t *testing.T) {
input := `
[build]
command = "hugo --gc --minify -b $URL"
[build.environment]
HUGO_VERSION = "0.1.1"
HUGO_ENABLEGITINFO = "true"`
expected := `
[build]
command = "hugo --gc --minify -b $URL"
[build.environment]
HUGO_VERSION = "0.83.1"
HUGO_ENABLEGITINFO = "true"`
real := updateVersion("0.83.1", input)
if real != expected {
t.Errorf("Expected %v and real %v)", expected, real)
}
}