forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate that extra params + resources aren't provided
While working on creating an end to end test for tektoncd#168, @dlorenc and I had a very hard time determining why our pipeline wasn't working as expected - it turned out that we were using the wrong resource name in our `providedBy` clauses. This is the first of a couple follow up commits to add more validation: this one makes sure that extra resources are not provided (e.g. if you typo-ed a param with a default value, you may never know your param was being ignored). (Shout out to @vdemeester - I updated the reconciler tests both before and after his test refactoring, and it was nearly impossible to understand the tests before his builders were added: the builders made it waaaaay easier! 🙏 Follow up on #124
- Loading branch information
1 parent
24449cf
commit 1bb816f
Showing
10 changed files
with
397 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright 2018 The Knative Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either extress or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package list | ||
|
||
// DiffLeft will return all strings which are in the left list of stirngs but | ||
// not in the right. | ||
func DiffLeft(left, right []string) []string { | ||
extra := []string{} | ||
for _, s := range left { | ||
found := false | ||
for _, s2 := range right { | ||
if s == s2 { | ||
found = true | ||
} | ||
} | ||
if !found { | ||
extra = append(extra, s) | ||
} | ||
} | ||
return extra | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Copyright 2018 The Knative Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either extress or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package list | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestDiffLeft_same(t *testing.T) { | ||
left := []string{"elsa", "anna", "olaf", "kristoff"} | ||
right := []string{"elsa", "anna", "olaf", "kristoff"} | ||
extraLeft := DiffLeft(left, right) | ||
|
||
if !reflect.DeepEqual(extraLeft, []string{}) { | ||
t.Errorf("Didn't expect extra strings in left list but got %v", extraLeft) | ||
} | ||
} | ||
|
||
func TestDiffLeft_extraLeft(t *testing.T) { | ||
left := []string{"elsa", "anna", "olaf", "kristoff", "hans"} | ||
right := []string{"elsa", "anna", "olaf", "kristoff"} | ||
extraLeft := DiffLeft(left, right) | ||
|
||
if !reflect.DeepEqual(extraLeft, []string{"hans"}) { | ||
t.Errorf("Should have identified extra string in left list but got %v", extraLeft) | ||
} | ||
} | ||
|
||
func TestDiffLeft_extraRight(t *testing.T) { | ||
left := []string{"elsa", "anna", "olaf", "kristoff"} | ||
right := []string{"elsa", "anna", "olaf", "kristoff", "hans"} | ||
extraLeft := DiffLeft(left, right) | ||
|
||
if !reflect.DeepEqual(extraLeft, []string{}) { | ||
t.Errorf("Shouldn't have noticed extra item in right list but got %v", extraLeft) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.