-
Notifications
You must be signed in to change notification settings - Fork 7
/
config_test.go
69 lines (54 loc) · 1.71 KB
/
config_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
// Copyright © 2016-present Thomas Rabaix <[email protected]>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package pkgmirror
import (
"testing"
"github.com/BurntSushi/toml"
"github.com/stretchr/testify/assert"
)
func Test_Config(t *testing.T) {
c := &Config{}
confStr := `
DataDir = "/var/lib/pkgmirror"
PublicServer = "https://mirror.example.com"
InternalServer = "localhost:8000"
[Composer]
[Composer.packagist]
Server = "https://packagist.org"
Enabled = true
[Composer.satis]
Server = "https://satis.internal.org"
Enabled = false
[Npm]
[Npm.npm]
Server = "https://registry.npmjs.org"
[Git]
[Git.github]
Server = "github.com"
Clone = "[email protected]:"
Enabled = true
[Static]
[Static.drupal]
Server = "drupal.org"
`
_, err := toml.Decode(confStr, c)
assert.NoError(t, err)
assert.Equal(t, "/var/lib/pkgmirror", c.DataDir)
assert.Equal(t, 2, len(c.Composer))
assert.Equal(t, "https://satis.internal.org", c.Composer["satis"].Server)
assert.Equal(t, false, c.Composer["satis"].Enabled)
assert.Equal(t, "https://packagist.org", c.Composer["packagist"].Server)
assert.Equal(t, true, c.Composer["packagist"].Enabled)
assert.Equal(t, 1, len(c.Npm))
assert.Equal(t, "https://registry.npmjs.org", c.Npm["npm"].Server)
assert.Equal(t, false, c.Npm["npm"].Enabled)
assert.Equal(t, 1, len(c.Git))
assert.Equal(t, "github.com", c.Git["github"].Server)
assert.Equal(t, "[email protected]:", c.Git["github"].Clone)
assert.Equal(t, true, c.Git["github"].Enabled)
assert.Equal(t, 1, len(c.Static))
assert.Equal(t, "drupal.org", c.Static["drupal"].Server)
assert.Equal(t, false, c.Static["drupal"].Enabled)
}