-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from gardener/removeemptynodes
Strip irrelevant nodes generated by resolved nodeSelector
- Loading branch information
Showing
4 changed files
with
178 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package reactor | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gardener/docforge/pkg/api" | ||
"github.com/gardener/docforge/pkg/resourcehandlers" | ||
) | ||
|
||
func Test_tasks(t *testing.T) { | ||
newDoc := createNewDocumentation() | ||
type args struct { | ||
node *api.Node | ||
tasks []interface{} | ||
lds localityDomain | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
expectedTasks []*DocumentWorkTask | ||
}{ | ||
{ | ||
name: "it creates tasks based on the provided doc", | ||
args: args{ | ||
node: newDoc.Root, | ||
tasks: []interface{}{}, | ||
}, | ||
expectedTasks: []*DocumentWorkTask{ | ||
{ | ||
Node: newDoc.Root, | ||
}, | ||
{ | ||
Node: archNode, | ||
}, | ||
{ | ||
Node: apiRefNode, | ||
}, | ||
{ | ||
Node: blogNode, | ||
}, | ||
{ | ||
Node: tasksNode, | ||
}, | ||
}, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
rhs := resourcehandlers.NewRegistry(&FakeResourceHandler{}) | ||
tasks(tc.args.node, &tc.args.tasks) | ||
|
||
if len(tc.args.tasks) != len(tc.expectedTasks) { | ||
t.Errorf("expected number of tasks %d != %d", len(tc.expectedTasks), len(tc.args.tasks)) | ||
} | ||
|
||
for i, task := range tc.args.tasks { | ||
if task.(*DocumentWorkTask).Node.Name != tc.expectedTasks[i].Node.Name { | ||
t.Errorf("expected task with Node name %s != %s", task.(*DocumentWorkTask).Node.Name, tc.expectedTasks[i].Node.Name) | ||
} | ||
} | ||
rhs.Remove() | ||
}) | ||
} | ||
} |
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 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