mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 09:20:31 +00:00
40 lines
512 B
Go
40 lines
512 B
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/BurntSushi/toml"
|
||
|
)
|
||
|
|
||
|
func TestRead(t *testing.T) {
|
||
|
var data = `
|
||
|
scheme = "https"
|
||
|
host = "localhost"
|
||
|
port = 8080
|
||
|
open = true
|
||
|
|
||
|
[github]
|
||
|
url = "https://github.com"
|
||
|
api = "https://api.github.com"
|
||
|
|
||
|
[bitbucket]
|
||
|
url = "https://bitbucket.org"
|
||
|
|
||
|
[smtp]
|
||
|
host = "smtp.drone.io"
|
||
|
port = "443"
|
||
|
user = "brad"
|
||
|
from = "brad@drone.io"
|
||
|
|
||
|
`
|
||
|
|
||
|
var conf Config
|
||
|
if _, err := toml.Decode(data, &conf); err != nil {
|
||
|
println(err.Error())
|
||
|
return
|
||
|
}
|
||
|
|
||
|
fmt.Printf("%#v\n", conf)
|
||
|
}
|