Skip to content

Commit

Permalink
Merge pull request kubernetes#46178 from zjj2wry/des_rq
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

add test in descibe resourcequota

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
  • Loading branch information
Kubernetes Submit Queue authored May 26, 2017
2 parents 7f8fd32 + fe44830 commit 25aa600
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkg/printers/internalversion/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1423,3 +1423,42 @@ URL: http://localhost
}
}
}

func TestDescribeResourceQuota(t *testing.T) {
fake := fake.NewSimpleClientset(&api.ResourceQuota{
ObjectMeta: metav1.ObjectMeta{
Name: "bar",
Namespace: "foo",
},
Status: api.ResourceQuotaStatus{
Hard: api.ResourceList{
api.ResourceName(api.ResourceCPU): resource.MustParse("1"),
api.ResourceName(api.ResourceLimitsCPU): resource.MustParse("2"),
api.ResourceName(api.ResourceLimitsMemory): resource.MustParse("2G"),
api.ResourceName(api.ResourceMemory): resource.MustParse("1G"),
api.ResourceName(api.ResourceRequestsCPU): resource.MustParse("1"),
api.ResourceName(api.ResourceRequestsMemory): resource.MustParse("1G"),
},
Used: api.ResourceList{
api.ResourceName(api.ResourceCPU): resource.MustParse("0"),
api.ResourceName(api.ResourceLimitsCPU): resource.MustParse("0"),
api.ResourceName(api.ResourceLimitsMemory): resource.MustParse("0G"),
api.ResourceName(api.ResourceMemory): resource.MustParse("0G"),
api.ResourceName(api.ResourceRequestsCPU): resource.MustParse("0"),
api.ResourceName(api.ResourceRequestsMemory): resource.MustParse("0G"),
},
},
})
c := &describeClient{T: t, Namespace: "foo", Interface: fake}
d := ResourceQuotaDescriber{c}
out, err := d.Describe("foo", "bar", printers.DescriberSettings{ShowEvents: true})
if err != nil {
t.Errorf("unexpected error: %v", err)
}
expectedOut := []string{"bar", "foo", "limits.cpu", "2", "limits.memory", "2G", "requests.cpu", "1", "requests.memory", "1G"}
for _, expected := range expectedOut {
if !strings.Contains(out, expected) {
t.Errorf("expected to find %q in output: %q", expected, out)
}
}
}

0 comments on commit 25aa600

Please sign in to comment.