本文整理汇总了Golang中testing.T.Spec方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Spec方法的具体用法?Golang T.Spec怎么用?Golang T.Spec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.T
的用法示例。
在下文中一共展示了T.Spec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestTemplateContext
func TestTemplateContext(t *testing.T) {
for _, testcase := range []struct {
Test string
Task *api.Task
Context Context
Expected *api.ContainerSpec
Err error
}{
{
Test: "Identity",
Task: modifyTask(func(t *api.Task) {
t.Spec = api.TaskSpec{
Runtime: &api.TaskSpec_Container{
Container: &api.ContainerSpec{
Env: []string{
"NOTOUCH=dont",
},
Mounts: []api.Mount{
{
Target: "foo",
Source: "bar",
},
},
},
},
}
}),
Expected: &api.ContainerSpec{
Env: []string{
"NOTOUCH=dont",
},
Mounts: []api.Mount{
{
Target: "foo",
Source: "bar",
},
},
},
},
{
Test: "Env",
Task: modifyTask(func(t *api.Task) {
t.Spec = api.TaskSpec{
Runtime: &api.TaskSpec_Container{
Container: &api.ContainerSpec{
Labels: map[string]string{
"ContainerLabel": "should-NOT-end-up-as-task",
},
Env: []string{
"MYENV=notemplate",
"{{.NotExpanded}}=foo",
"SERVICE_ID={{.Service.ID}}",
"SERVICE_NAME={{.Service.Name}}",
"TASK_ID={{.Task.ID}}",
"TASK_NAME={{.Task.Name}}",
"NODE_ID={{.Node.ID}}",
"SERVICE_LABELS={{range $k, $v := .Service.Labels}}{{$k}}={{$v}},{{end}}",
},
},
},
}
}),
Expected: &api.ContainerSpec{
Labels: map[string]string{
"ContainerLabel": "should-NOT-end-up-as-task",
},
Env: []string{
"MYENV=notemplate",
"{{.NotExpanded}}=foo",
"SERVICE_ID=serviceID",
"SERVICE_NAME=serviceName",
"TASK_ID=taskID",
"TASK_NAME=serviceName.10.taskID",
"NODE_ID=nodeID",
"SERVICE_LABELS=ServiceLabelOneKey=service-label-one-value,ServiceLabelTwoKey=service-label-two-value,com.example.ServiceLabelThreeKey=service-label-three-value,",
},
},
},
{
Test: "Mount",
Task: modifyTask(func(t *api.Task) {
t.Spec = api.TaskSpec{
Runtime: &api.TaskSpec_Container{
Container: &api.ContainerSpec{
Mounts: []api.Mount{
{
Source: "bar-{{.Node.ID}}-{{.Task.Name}}",
Target: "foo-{{.Service.ID}}-{{.Service.Name}}",
},
{
Source: "bar-{{.Node.ID}}-{{.Service.Name}}",
Target: "foo-{{.Task.Slot}}-{{.Task.ID}}",
},
},
},
},
}
}),
Expected: &api.ContainerSpec{
Mounts: []api.Mount{
//.........这里部分代码省略.........