本文整理汇总了Golang中github.com/asciinema/asciinema/util.Config类的典型用法代码示例。如果您正苦于以下问题:Golang Config类的具体用法?Golang Config怎么用?Golang Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestConfig_ApiUrl
func TestConfig_ApiUrl(t *testing.T) {
var tests = []struct {
cfg util.ConfigFile
env map[string]string
expected string
}{
{
util.ConfigFile{},
map[string]string{},
"https://asciinema.org",
},
{
util.ConfigFile{API: util.ConfigAPI{URL: "https://asciinema.example.com"}},
map[string]string{},
"https://asciinema.example.com",
},
{
util.ConfigFile{API: util.ConfigAPI{URL: "https://asciinema.example.com"}},
map[string]string{"ASCIINEMA_API_URL": "http://localhost:3000"},
"http://localhost:3000",
},
}
for _, test := range tests {
cfg := util.Config{&test.cfg, test.env}
actual := cfg.ApiUrl()
if actual != test.expected {
t.Errorf(`expected "%v", got "%v"`, test.expected, actual)
}
}
}
示例2: TestConfig_RecordCommand
func TestConfig_RecordCommand(t *testing.T) {
var tests = []struct {
cfg util.ConfigFile
env map[string]string
expected string
}{
{
util.ConfigFile{},
map[string]string{},
"/bin/sh",
},
{
util.ConfigFile{},
map[string]string{"SHELL": "/bin/bash"},
"/bin/bash",
},
{
util.ConfigFile{Record: util.ConfigRecord{Command: "foo -l"}},
map[string]string{"SHELL": "/bin/bash"},
"foo -l",
},
}
for _, test := range tests {
cfg := util.Config{&test.cfg, test.env}
actual := cfg.RecordCommand()
if actual != test.expected {
t.Errorf(`expected "%v", got "%v"`, test.expected, actual)
}
}
}
示例3: TestConfig_ApiToken
func TestConfig_ApiToken(t *testing.T) {
var tests = []struct {
cfg util.ConfigFile
expected string
}{
{
util.ConfigFile{},
"",
},
{
util.ConfigFile{API: util.ConfigAPI{Token: "foo"}},
"foo",
},
{
util.ConfigFile{User: util.ConfigUser{Token: "foo"}},
"foo",
},
}
for _, test := range tests {
cfg := util.Config{&test.cfg, nil}
actual := cfg.ApiToken()
if actual != test.expected {
t.Errorf(`expected "%v", got "%v"`, test.expected, actual)
}
}
}
示例4: TestConfig_PlayMaxWait
func TestConfig_PlayMaxWait(t *testing.T) {
var tests = []struct {
cfg util.ConfigFile
expected float64
}{
{
util.ConfigFile{},
0,
},
{
util.ConfigFile{Play: util.ConfigPlay{MaxWait: 1.23456}},
1.23456,
},
}
for _, test := range tests {
cfg := util.Config{&test.cfg, nil}
actual := cfg.PlayMaxWait()
if actual != test.expected {
t.Errorf(`expected "%v", got "%v"`, test.expected, actual)
}
}
}
示例5: TestConfig_RecordYes
func TestConfig_RecordYes(t *testing.T) {
var tests = []struct {
cfg util.ConfigFile
expected bool
}{
{
util.ConfigFile{},
false,
},
{
util.ConfigFile{Record: util.ConfigRecord{Yes: true}},
true,
},
}
for _, test := range tests {
cfg := util.Config{&test.cfg, nil}
actual := cfg.RecordYes()
if actual != test.expected {
t.Errorf(`expected "%v", got "%v"`, test.expected, actual)
}
}
}
示例6: TestConfig_RecordMaxWait
func TestConfig_RecordMaxWait(t *testing.T) {
var tests = []struct {
cfg util.ConfigFile
expected uint
}{
{
util.ConfigFile{},
0,
},
{
util.ConfigFile{Record: util.ConfigRecord{MaxWait: 1}},
1,
},
}
for _, test := range tests {
cfg := util.Config{&test.cfg, nil}
actual := cfg.RecordMaxWait()
if actual != test.expected {
t.Errorf(`expected "%v", got "%v"`, test.expected, actual)
}
}
}