-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig_test.go
More file actions
29 lines (25 loc) · 946 Bytes
/
Copy pathconfig_test.go
File metadata and controls
29 lines (25 loc) · 946 Bytes
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
package xtemplate
import "testing"
func TestConfigMinifyDefault(t *testing.T) {
// New() (the documented constructor) defaults Minify to true, matching the
// CLI's default:"true" tag.
if m := New().Minify; m == nil || !*m {
t.Error("New() should default Minify to true")
}
// Defaults() must default an unset (nil) Minify to true, so the documented
// default holds regardless of construction path (not just via New()).
c := &Config{}
c.SetDefaults()
if c.Minify == nil || !*c.Minify {
t.Error("Defaults() should default an unset Minify to true")
}
// An explicit Minify=false must survive re-application of Defaults, which
// Server and Instance call internally. If Defaults clobbered it, minify
// could never be disabled via the Go API.
explicitFalse := false
c = &Config{Minify: &explicitFalse}
c.SetDefaults()
if c.Minify == nil || *c.Minify {
t.Error("Defaults() must not clobber an explicit Minify=false")
}
}