-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 #11249 from soltysh/issue9502
Merged by openshift-bot
- Loading branch information
Showing
8 changed files
with
278 additions
and
101 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,31 @@ | ||
package prune | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/openshift/origin/pkg/client/testclient" | ||
) | ||
|
||
func TestBuildPruneNamespaced(t *testing.T) { | ||
osFake := testclient.NewSimpleFake() | ||
opts := &PruneBuildsOptions{ | ||
Namespace: "foo", | ||
|
||
OSClient: osFake, | ||
Out: ioutil.Discard, | ||
} | ||
|
||
if err := opts.Run(); err != nil { | ||
t.Errorf("Unexpected error: %v", err) | ||
} | ||
|
||
if len(osFake.Actions()) == 0 { | ||
t.Errorf("Missing get build actions") | ||
} | ||
for _, a := range osFake.Actions() { | ||
if a.GetNamespace() != "foo" { | ||
t.Errorf("Unexpected namespace while pruning %s: %s", a.GetResource(), a.GetNamespace()) | ||
} | ||
} | ||
} |
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,40 @@ | ||
package prune | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
|
||
ktestclient "k8s.io/kubernetes/pkg/client/unversioned/testclient" | ||
|
||
"github.com/openshift/origin/pkg/client/testclient" | ||
) | ||
|
||
func TestDeploymentPruneNamespaced(t *testing.T) { | ||
kFake := ktestclient.NewSimpleFake() | ||
osFake := testclient.NewSimpleFake() | ||
opts := &PruneDeploymentsOptions{ | ||
Namespace: "foo", | ||
|
||
OSClient: osFake, | ||
KClient: kFake, | ||
Out: ioutil.Discard, | ||
} | ||
|
||
if err := opts.Run(); err != nil { | ||
t.Errorf("Unexpected error: %v", err) | ||
} | ||
|
||
if len(osFake.Actions()) == 0 || len(kFake.Actions()) == 0 { | ||
t.Errorf("Missing get deployments actions") | ||
} | ||
for _, a := range osFake.Actions() { | ||
if a.GetNamespace() != "foo" { | ||
t.Errorf("Unexpected namespace while pruning %s: %s", a.GetResource(), a.GetNamespace()) | ||
} | ||
} | ||
for _, a := range kFake.Actions() { | ||
if a.GetNamespace() != "foo" { | ||
t.Errorf("Unexpected namespace while pruning %s: %s", a.GetResource(), a.GetNamespace()) | ||
} | ||
} | ||
} |
Oops, something went wrong.