Skip to content

Commit

Permalink
removes build references from variables names
Browse files Browse the repository at this point in the history
  • Loading branch information
hrishin committed Apr 30, 2019
1 parent 28eecf2 commit 14d476b
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions pkg/apis/pipeline/v1alpha1/task_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ var validResource = TaskResource{
Type: "git",
}

var validBuildSteps = []corev1.Container{{
var validSteps = []corev1.Container{{
Name: "mystep",
Image: "myimage",
}}

var invalidBuildSteps = []corev1.Container{{
var invalidSteps = []corev1.Container{{
Name: "replaceImage",
Image: "myimage",
}}

func TestTaskSpecValidate(t *testing.T) {
type fields struct {
Inputs *Inputs
Outputs *Outputs
BuildSteps []corev1.Container
Inputs *Inputs
Outputs *Outputs
Steps []corev1.Container
}
tests := []struct {
name string
Expand All @@ -63,15 +63,15 @@ func TestTaskSpecValidate(t *testing.T) {
},
},
},
BuildSteps: validBuildSteps,
Steps: validSteps,
},
}, {
name: "valid outputs",
fields: fields{
Outputs: &Outputs{
Resources: []TaskResource{validResource},
},
BuildSteps: validBuildSteps,
Steps: validSteps,
},
}, {
name: "both valid",
Expand All @@ -82,7 +82,7 @@ func TestTaskSpecValidate(t *testing.T) {
Outputs: &Outputs{
Resources: []TaskResource{validResource},
},
BuildSteps: validBuildSteps,
Steps: validSteps,
},
}, {
name: "valid template variable",
Expand All @@ -101,7 +101,7 @@ func TestTaskSpecValidate(t *testing.T) {
Outputs: &Outputs{
Resources: []TaskResource{validResource},
},
BuildSteps: []corev1.Container{{
Steps: []corev1.Container{{
Name: "mystep",
Image: "${inputs.resources.foo.url}",
Args: []string{"--flag=${inputs.params.baz} && ${input.params.foo-is-baz}"},
Expand All @@ -114,7 +114,7 @@ func TestTaskSpecValidate(t *testing.T) {
ts := &TaskSpec{
Inputs: tt.fields.Inputs,
Outputs: tt.fields.Outputs,
Steps: tt.fields.BuildSteps,
Steps: tt.fields.Steps,
}
if err := ts.Validate(context.Background()); err != nil {
t.Errorf("TaskSpec.Validate() = %v", err)
Expand All @@ -125,9 +125,9 @@ func TestTaskSpecValidate(t *testing.T) {

func TestTaskSpecValidateError(t *testing.T) {
type fields struct {
Inputs *Inputs
Outputs *Outputs
BuildSteps []corev1.Container
Inputs *Inputs
Outputs *Outputs
Steps []corev1.Container
}
tests := []struct {
name string
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestTaskSpecValidateError(t *testing.T) {
validResource,
},
},
BuildSteps: validBuildSteps,
Steps: validSteps,
},
expectedError: apis.FieldError{
Message: `invalid value: what`,
Expand All @@ -190,7 +190,7 @@ func TestTaskSpecValidateError(t *testing.T) {
validResource,
},
},
BuildSteps: validBuildSteps,
Steps: validSteps,
},
expectedError: apis.FieldError{
Message: `invalid value: what`,
Expand All @@ -210,7 +210,7 @@ func TestTaskSpecValidateError(t *testing.T) {
validResource,
},
},
BuildSteps: validBuildSteps,
Steps: validSteps,
},
expectedError: apis.FieldError{
Message: "expected exactly one, got both",
Expand All @@ -230,7 +230,7 @@ func TestTaskSpecValidateError(t *testing.T) {
validResource,
},
},
BuildSteps: validBuildSteps,
Steps: validSteps,
},
expectedError: apis.FieldError{
Message: "expected exactly one, got both",
Expand All @@ -242,7 +242,7 @@ func TestTaskSpecValidateError(t *testing.T) {
Inputs: &Inputs{
Resources: []TaskResource{validResource},
},
BuildSteps: []corev1.Container{},
Steps: []corev1.Container{},
},
expectedError: apis.FieldError{
Message: "missing field(s)",
Expand All @@ -254,7 +254,7 @@ func TestTaskSpecValidateError(t *testing.T) {
Inputs: &Inputs{
Resources: []TaskResource{validResource},
},
BuildSteps: invalidBuildSteps,
Steps: invalidSteps,
},
expectedError: apis.FieldError{
Message: `invalid value "replaceImage"`,
Expand All @@ -264,7 +264,7 @@ func TestTaskSpecValidateError(t *testing.T) {
}, {
name: "inexistent input param variable",
fields: fields{
BuildSteps: []corev1.Container{{
Steps: []corev1.Container{{
Name: "mystep",
Image: "myimage",
Args: []string{"--flag=${inputs.params.inexistent}"},
Expand All @@ -277,7 +277,7 @@ func TestTaskSpecValidateError(t *testing.T) {
}, {
name: "inexistent input resource variable",
fields: fields{
BuildSteps: []corev1.Container{{
Steps: []corev1.Container{{
Name: "mystep",
Image: "myimage:${inputs.resources.inputs}",
}},
Expand All @@ -289,7 +289,7 @@ func TestTaskSpecValidateError(t *testing.T) {
}, {
name: "inexistent output param variable",
fields: fields{
BuildSteps: []corev1.Container{{
Steps: []corev1.Container{{
Name: "mystep",
Image: "myimage",
WorkingDir: "/foo/bar/${outputs.resources.inexistent}",
Expand All @@ -311,7 +311,7 @@ func TestTaskSpecValidateError(t *testing.T) {
},
},
},
BuildSteps: []corev1.Container{{
Steps: []corev1.Container{{
Name: "mystep",
Image: "myimage",
Args: []string{"${inputs.params.foo} && ${inputs.params.inexistent}"},
Expand All @@ -327,7 +327,7 @@ func TestTaskSpecValidateError(t *testing.T) {
ts := &TaskSpec{
Inputs: tt.fields.Inputs,
Outputs: tt.fields.Outputs,
Steps: tt.fields.BuildSteps,
Steps: tt.fields.Steps,
}
err := ts.Validate(context.Background())
if err == nil {
Expand Down

0 comments on commit 14d476b

Please sign in to comment.